Js scroll wheel for screen cutting

Source: Internet
Author: User

Js scroll wheel for screen cutting

Because the entire project is not self-written, it just helps others write js scroll code, and other projects are not yet online, so only part of the code that I wrote is posted,

Effect: When the scroll wheel is clicked, the screen on the Web tracking page is switched up and down.

(The following code has been successfully tested on IE, chrome, and FireFox browsers on the local computer)

Var sum = 0; var oTxt = document. getElementById ("txt"); var scrollFunc = function (e) {var direct = 0; var men = $ (". menu_m "). find (". menu "). find ("li"); men. each (function (j) {if ($ (this ). attr ("class") = "m_selected") {sum = j ;}}); e = e | window. event; if (e. wheelDelta) {// IE/Opera/Chrome if (navigator. appName = 'netscape ') {// Chorme rolls twice, so 0.5 if (e. wheelDelta> 0) {sum = parseFloat (sum-0.5);} else {sum = parseFloat (sum) + 0.5 ;}} else {if (e. wheelDelta> 0) sum = parseFloat (sum-1); else sum = parseFloat (sum + 1) ;}} else if (e. detail) {// Firefox // The upward and downward values of firefox are not the same as those above. You can print out if (e. detail> 0) sum = parseFloat (sum + 1); else sum = parseFloat (sum-1) ;}// sum, the following is what you want to do, here, I want to write a screen jump that is associated with the current project, but add return false. Otherwise, it will appear in google and ie, var sizes =$ (". menu_m "). find (". menu "). find ("li "). size (); if (sum> = 0 & parseFloat (sum) <= parseFloat (sizes)-1) {men. each (function (j) {$ (this ). removeClass ("m_selected")}); $ (". menu_m "). find (". menu li: eq ("+ sum + ")"). find ("span "). click (); return false ;}}/* Register event */if (document. addEventListener) {document. addEventListener ('domainscroll', scrollFunc, false);} // W3Cwindow. onmousewheel = document. onmousewheel = scrollFunc; // IE/Opera/Chrome/Safari

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.