0
我與滾動事件,並在我已經看過我幾個劇本實驗發現這一行:onmousewheel,在窗口或文檔上?
window.onmousewheel = document.onmousewheel = somefunc;
這是工作爲目的,在somefunc被觸發滾動。我的問題是,Chrome會觸發該功能兩次(很明顯,因爲Chrome對窗口和文檔事件都響應)。我想知道爲什麼使用這兩個事件,是否由於跨瀏覽器兼容性?如果是這樣,哪個瀏覽器喜歡哪個事件?我只想選擇其中的一個,但我不知道是哪一個。
您應該始終使用窗口 – Chrillewoodz
顯示somefunc代碼,可能會出現一些問題。沒有錯window.onmousewheel = document.onmousewheel –
爲什麼這麼受歡迎使用文件呢? – theva