Hello, before to post i try to search a solution in this site and by google but with now luck.
I have a issue with IE8, this code below add on the fly an IFRAME and work fine in Chrome, Firefox and IE7.
The problem is the keyHandler() function that is not triggered only in IE8.
What is the best solution to attach an event crossbrowser as onkeydown?
(also Safari and Opera will be nice to support, will be IE9 also supported with this code?)
p.s. i currently use prototype.js, the embeded blank.htm have the contenteditable on and the properly DOCTYPE -> (also in the main page where the function is called)
I post the code below and thanks in advance for suggestion and tips
function addFrame() {
var editorFrame = 'myEditor', iFrame;
var newFrame = new Element('iframe', {width: '320px', height: '70px',id: editorFrame, name: editorFrame, src:'/blank.htm'});
$('container').appendChild(newFrame);
if(document.all) {
iFrame = window.frames[editorFrame];
if (window.document.addEventListener)
iFrame.document.addEventListener('keydown', keyHandler, false);
else
iFrame.document.attachEvent('onkeydown', keyHandler); // OK IE7
}
else {
// OK Firefox, Chrome
iFrame = $(editorFrame).contentWindow;
iFrame.addEventListener('keydown', keyHandler, false);
}
}