滾輪事件onmousewheel

2022-05-06 12:30:13 字數 727 閱讀 4086

1、滾動條事件 : document.onscroll  = function()  

2、滾輪事件 :document.onmousewheel = function ()  (

firefox 不支援)

(1) event.wheeldelta > 0 :滾輪向上

(120)

(2) event.wheeldelta < 0 :滾輪向下

(-120)

dommousescroll (使用addeventlistener事件繫結)

(event.detail < 0:滾輪向上,event.detail > 0:滾輪向下)【firefox支援方法】

使用call引用物件 ,相容火狐的滾輪事件

function  scroll (obj , fun )else

function fun_nei (event ,down )else

}if(window.stoppropagation)

else

return false ; 

}在其他地方,scroll() 函式外或另乙個html文件裡引用 scroll():

(1) :scroll ( 【document或具體物件】,   function (event , down ) );

(2):function hans(event , down )

scroll ( document【或具體物件】,  hans ) ;

滑鼠滾輪事件

新增事件 有相容性 註冊事件 if document.addeventlistener window.onmousewheel document.onmousewheel scrollfunc ie opera chrome detail與wheeldelta 判斷滾輪向上或向下在瀏覽器中也有相容性...

滑鼠滾輪事件

新增事件 有相容性 註冊事件 if document.addeventlistener window.onmousewheel document.onmousewheel scrollfunc ie opera chrome detail與wheeldelta 判斷滾輪向上或向下在瀏覽器中也有相容性...

滑鼠滾輪事件

滑鼠滾輪事件和鍵盤事件以及滑鼠左右鍵沒本質的區別。2 if document.addeventlistener window.onmousewheel document.onmousewheel scroll ie opera chrome safari 像上面這樣就可以給整個文件繫結滾輪事件。fu...