How can I prevent scrolling in an iframe while the user has their mouse over the iframe?
This is the code I'm using:
JavaScript
function preventDefault(e){
e = e || window.event;
if( e.preventDefault )
e.preventDefault();
e.returnValue = false;
}
document.getElementById('a').onmousewheel = function(e){
console.log(this);
document.getElementById('a').scrollTop -= e. wheelDeltaY;
preventDefault(e);
}
HTML
<div>
<iframe id='a' src='http://www.google.com/intl/en/about/index.html'></iframe>
</div>
CSS
div{ height:1000px }
iframe{ margin:200px; }
Here is an example JS Fiddle. It works fine in Chrome but not in FF. Desirable behavior should be the following: whole page (body) should not scroll while mouseover event on iframe occurs: no matter how much text inside iframe (with scrollbar http://jsfiddle.net/2QcVJ/23/ or without http://jsfiddle.net/2QcVJ/25/);
Any thoughts how to do that? Thanks in advance