window.onload=function(){ 
document.onmousewheel   =   function()
{
if(evt.ctrlKey)  
 return   false;} 
}
  
上面代码在ie中正常有效,请问在火狐中该怎么写?在线等

解决方案 »

  1.   

    window.onload=function(){ 
    document.onmousewheel  =  function(evt

    if(evt.ctrlKey)  
    return  false;} 

      
      

  2.   

    document.onmousewheel  =  function(evt)
      

  3.   

    不好意思,原来正确的代码是
    window.onload=function(){ 
    document.onmousewheel   =   function(){if(event.ctrlKey)   return   false;} 
    }
    ,我这个不是在点击button之类调用的,直接页面的时候就处理,所以传参数应该没什么大碍,主要是浏览器事件不同可能
      

  4.   

    因为ie和ff对于event的参数传递和使用不同。
    ie中event是全局变量,ff中event作为第一个参数传递
    window.onload=function(){ 
    document.onmousewheel = function(e){
    e=e||event;
    if(e.ctrlKey) return false;

      

  5.   

    火狐里面要在函数里使用事件, 必须在函数的第一个参数引用事件现场. 至于写成evt还是event都无所谓document.onmousewheel = function (evt) 
    {
    var e = evt || window.event;
    if(e.preventDefault) e.preventDefault();
    e.returnValue = false;

    if (window.addEventListener) window.addEventListener('DOMMouseScroll', document.onmousewheel, false);//火狐必须用addEventListener来注册mousewheel事件
      

  6.   

    楼上正解,不过屏蔽得过了,我值要屏蔽ctil+滚轮的
    改了下:
    document.onmousewheel = function (evt) 
    {
        var e = evt || window.event;
        if(e.preventDefault && e.ctrlKey) e.preventDefault();
        if(e.ctrlKey) e.returnValue = false;

    if (window.addEventListener) window.addEventListener('DOMMouseScroll', document.onmousewheel, false);
      

  7.   

    if (window.addEventListener) window.addEventListener('DOMMouseScroll', document.onmousewheel, false);火狐的这个方法我试过了,屏蔽不了呀?怎么办?