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

Need to disable mousewheel when cursor enters swf object

本文关键字:鼠标 光标 swf 对象      更新时间:2023-09-26

基本上页面运行一个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

使用event.preventDefault()return false;

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

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

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