How can I prevent an HTML page from scrolling when arrow keys are pressed if an iframe inside it is focused?
I'm gettting this error in Chrome
The iframe is focused, I know its focused. The parent scrolls anyway.
The following code inside the iframe document will prevent it from scrolling:
document.onkeydown = function(evt) {
evt = evt || window.event;
var keyCode = evt.keyCode;
if (keyCode >= 37 && keyCode <= 40) {
return false;
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With