Disable Mousewheel Scroll On Swf Files?
I am using the scroll in a swf file.. is there anyway to disable the scroll mousewheel on all browsers.. I get it working for IE and FF but Webkit is not working: $(document).ready
Solution 1:
With the help of some scripts from the web and JQuery i have assembled the following Javascript solution for the problem and it works fine on all browsers.
Based on: http://adomas.org/javascript-mouse-wheel/
Just disable when the mouse enters the container div and re-enable the mouse onMouseLeave
.
jQuery(function(){
$("#myFlashContainer").mouseenter(
function () {
if (window.addEventListener)
{
window.removeEventListener('DOMMouseScroll', wheelOn, false);
window.addEventListener('DOMMouseScroll', wheelOff, false);
}
/** IE/Opera. **/
window.onmousewheel = document.onmousewheel = wheelOff;
}
);
$("#myFlashContainer").mouseleave(
function () {
if (window.addEventListener)
{
window.removeEventListener('DOMMouseScroll', wheelOff, false);
window.addEventListener('DOMMouseScroll', wheelOn, false);
}
/** IE/Opera. **/
window.onmousewheel = document.onmousewheel = wheelOn;
}
);
function wheelOff(event)
{
var delta = 0;
if (!event) /* For IE. */
event = window.event;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta/120;
} else if (event.detail) { /** Mozilla case. */
/** In Mozilla, sign of delta is different than in IE.
* Also, delta is multiple of 3.
*/
// delta = -event.detail/3;
}
if (event.preventDefault)
event.preventDefault();
event.returnValue = false;
}
function wheelOn(event)
{
var delta = 0;
if (!event) /* For IE. */
event = window.event;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta/120;
} else if (event.detail) { /** Mozilla case. */
// delta = -event.detail/3;
}
if (event.preventDefault)
{
//event.preventDefault();
event.returnValue = true;
}
return true;
}
});
Post a Comment for "Disable Mousewheel Scroll On Swf Files?"