Horizontal scroll bars are moved and problem-handled according to the scrolling of the rollers

Source: Internet
Author: User

When working on a project today, use the ' horizontal scroll bar to move through the scroll wheel '

Got a lot of information on the Internet.

Also found some plug-ins! It's not very useful.

And I probably checked the information myself.

To find a presumably more reliable

Html

<style= "width:5000px;" >Test</div>

Jquery

$(function() {    //sets the length of each scroll, per px    varScroll_width = 100; varscroll_events = "MouseWheel dommousescroll mozmousepixelscroll"; $ (document). On (Scroll_events,function(e) {varDelta = E.originalevent.wheeldelta | |E.originalevent.detail; //the pulley scrolls down, the scroll bar moves to the right, scrollleft+        if(Delta > 0) {            $("HTML"). ScrollLeft ($ ("html"). ScrollLeft () +scroll_width); }        //The pulley rolls upward, the scroll bar moves toward the seat, scrollleft-        Else {            $("HTML"). ScrollLeft ($ ("html"). ScrollLeft ()-scroll_width); }    });});

Javascript

Window.onload =function() {    //Monitor mouse wheel    varMousewheelevt = (/firefox/i.test (navigator.useragent))? "Dommousescroll": "MouseWheel"; if(document.attachevent) {document.attachevent ("On" + mousewheelevt,function(e) {mousewheel_event (E.wheeldelta);    }); }    Else if(Document.addeventlistener) {Document.addeventlistener (mousewheelevt,function(e) {mousewheel_event (e.detail); }, false); }                //sets the length of each scroll, per px    varScroll_width = 100; functionmousewheel_event (delta) {//the pulley scrolls down, the scroll bar moves to the right, scrollleft+        if(Delta > 0) {document.getElementsByTagName ("HTML") [0].scrollleft+=Scroll_width; }        //The pulley rolls upward, the scroll bar moves toward the seat, scrollleft-        Else{document.getelementsbytagname ("HTML") [0].scrollleft-=Scroll_width; }    }};

Reference: Http://zhidao.baidu.com/link?url= Yp2gvssadxq1t2dox5idha0xdel5k7rssiffclgg9dmxsjrxtdklldwresxvo8uok1yrquyvou9p-ssorpc2f_

jquery method I tried it. Found in IE OK under chrome does not perform properly

I looked for the next reason.

Discover Chrome under

$ ("HTML"). ScrollLeft ()

Forever is 0

In the domestic find no solution to go

http://stackoverflow.com/found it. Keywords: Chrome scrollleft

Sure enough to find an article

Http://stackoverflow.com/questions/13927430/html-scrollleftvalue-not-working-in-chrome

It turns out that Chrome doesn't work

$ ("HTML"). ScrollLeft () and requires $ (window). scrollleft (100);

Horizontal scroll bars are moved and problem-handled according to the scrolling of the rollers

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.