当光标进入swf对象时需要禁用鼠标滚轮

时间:2011-12-19 22:07:56

标签: javascript jquery flash mousewheel

基本上该页面运行swf游戏。如果光标位于游戏中,则需要禁用鼠标滚轮功能。

这就是我试过的

jQuery(document).ready(function(){
  jQuery('#gameplay-container').mouseenter(function(){
    document.onmousewheel = function(){
      return false
    }
  });
  jQuery('#gameplay-container').mouseout(function(){
    document.onmousewheel = function() {
      return true;
    }
  });
});

似乎根本不起作用。当你在div上盘旋时,我确实找到了一种禁用滚动的方法,但是一旦加载了flash对象,它就会停止运行。 Flash wmode设置为透明,但也尝试了不透明。 #gameplay-container是包含flash对象的div。

2 个答案:

答案 0 :(得分:0)

使用event.preventDefault()return false;

function(event) { event.preventDefault(); return false; }

答案 1 :(得分:0)

尝试直接使用鼠标滚轮功能:

 $("#gameplay-container").bind("mousewheel", function() {
         return false;
     });