ie/opera屬於同一型別,使用attachevent即可新增滾輪事件。
/*ie註冊事件
*/if
(document.attachevent)
firefox使用addeventlistener新增滾輪事件 。
/*firefox註冊事件
*/if
(document.addeventlistener)
safari與chrome屬於同一型別,可使用html dom方式新增事件
window.onmousewheel=document.onmousewheel=scrollfunc;//ie/opera/chrome
其中除firefox外其餘均可使用html dom方式新增事件,因此新增事件使用以下方式
/*註冊事件
*/if
(document.addeventlistener)
//w3c
window.onmousewheel=document.onmousewheel=scrollfunc;//
ie/opera/chrome
滑鼠滾輪事件
新增事件 有相容性 註冊事件 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...