onmousewheel跟onscroll的區別


研習DOM中的事件方法,發現一些細微差別,百度一下沒有類似的解答,隨手記下來。

onmousewheel事件 

以下摘自http://help.dottoro.com/ljmracjb.php

Browser support:

IE,火狐,opera,sarafi,chrome

Occurs when the mouse wheel rolls.
In Firefox, use the DOMMouseScroll event and the detail event property instead.
Note: the onmousewheel and DOMMouseScroll events are also fired on elements that have no scrollbar or when the contents are not scrolled. If you would like to receive a notification when the contents of an element are scrolled, use the onscroll event.
 
翻譯:該事件發生在鼠標滾輪滾動時,火狐中,使用DOMMouseScroll跟其細節事件(參看http://help.dottoro.com/ljrxdxdw.php及http://www.feiesoft.com/html/events/onmousewheel.html)代替。注意:onmousewheel和DOMMouseScroll事件,在沒有滾動條或者內容沒有被滾動的時候也會發生,意思是只要鼠標動不管頁面動不動。如果你是想一個元素內容滾動后接受一個通知的話,使用onscroll事件。
 
onscroll事件
 
Browser support:
IE,火狐,opera,sarafi,chrome
Occurs when the contents of an element have been scrolled.
This event is only fired on elements that have a scrollbar. Use the overflow style property to create scrollbars for an element.
 
翻譯:事件發生在元素內容滾動的時候,也包括鍵盤上下鍵,載入也可觸發。事件僅僅在有滾動條時發生,使用overflow屬性為元素創建一個滾動條。
 
ok,就這樣。
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM