Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable JavaScript keypress events in iframes

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.

like image 230
cllpse Avatar asked Dec 18 '25 16:12

cllpse


1 Answers

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.

like image 181
VonC Avatar answered Dec 20 '25 06:12

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!