Home > Web Front-end > JS Tutorial > body text

javascript compatible mouse wheel event_javascript skills

WBOY
Release: 2016-05-16 18:54:40
Original
1055 people have browsed it

This event is different under standards and IE. Firefox is implemented according to standards, and the event name is "DOMMouseScroll", while IE uses "mousewheel".
Of course one line of code solves the compatibility problem

Copy the code The code is as follows:

var mousewheel = document.all?"mousewheel":"DOMMouseScroll";

Event attribute, IE is event.wheelDelta, Firefox is event.detail. The direction value of the attribute is also different, IE upward Scroll > 0, Firefox scroll down > 0.
The latest jquery 1.3.2 still does not add wheel events, but you can use jquery's bind to bind any event, of course you must add the above sentence.
However, there is a plug-in for jquery that has added this function. See http://brandonaaron.net/code/mousewheel/demos
Use like this:
Copy the codeThe code is as follows:

$('div.mousewheel_example').mousewheel(fn);
$('div.mousewheel_example').bind('mousewheel', fn);
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!