views:

1606

answers:

1

How do I disable the support for JavaScript keypress events in iframes?

I need keypress events disabled only in specific iframes, so doing a catch-all-events-and-make-em-do-nothing solution is not an option.

+3  A: 

Does this example does what you want ?

According to this thread, something along the line of:

document.getElementById('edit').contentWindow.addEventListener('keypress', cK, true);

helps capturing keypress in a given iframe. If they can be captured, they can be disabled.

Warning: as pointed out by Allain Lalonde in the comments:

This will work if the iframe's content isn't from another domain.

VonC
This will work if the iframe's content isn't from another domain. Thought that might be relevant.
Allain Lalonde