Adding events to iframe which has designMode set to ‘on’ (firefox)

Being looking for this for a while, then I found that firefox disables the events for a iframe when the designMode is set to “on”. But I kept on searching for a hack for this, which eventually brought me to the following code which works perfectly.

document.getElementById('iView').contentWindow.addEventListener('keypress',keypress, true);
function keypress(e){
   //Do something
}

Tags: , , ,

One Response to “Adding events to iframe which has designMode set to ‘on’ (firefox)”

  1. Anderson Florence (@anderson_f) Says:

    Thanks you SOOO much!!! Who knew it was just a matter of using contentWindow instead of contentDocument

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: