views:

219

answers:

2

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(function() {
$("#ebook").hover(
  function () {
    document.onmousewheel = function(){
        return false
    };
    console.log('On');
  },
  function () {
    console.log('Out');
    document.onmousewheel = function() {
        return true;
    }
  }
);

});

A: 

Omg ok actually it works.. but the listener needs to be on a container div and cannot be directly on the object tag.

(And it needs some padding to work in webkit)

Chris
A: 

Hiya, in case anybody is interested: With the help of some scripts from the web and jquery i have assemled 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; /* In Opera 9, delta differs in sign as compared to IE. / if (window.opera) delta = -delta; } 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; /* In Opera 9, delta differs in sign as compared to IE. / if (window.opera) delta = -delta; } else if (event.detail) { /* Mozilla case. */

// delta = -event.detail/3; } if (event.preventDefault) { //event.preventDefault(); event.returnValue = true; } return true; }

});

karstor
This seems to work in firefox / webkit.. but not IE 8... also it does not set focus to an .swf
Chris