JavaScript three group text gap scrolling instance code _javascript tips

Source: Internet
Author: User

<ptml> <pead> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "> <meta http-equiv=" content-language "content=" ZH-CN "> <title> three Group text gap rolling </title> <style type= "Text/css" > *{font-size:12px;} #scrollBox2 {width:150px; height:64px; line-height:22px; overflow:hidden; Background-color: #eee;} </style> </pead> <body> National currency name today <div id= "ScrollBox2" > USD usdŀ.775%<br> HKD hkdŀ.75%<br> Sterling gbpŀ.50%<br> euro eurŀ.25%<br> Yen jpyŀ.01%<br> </di V> <script> window.onload=function () {New Marquee ("ScrollBox2",//container id<br> 0,//scroll up (0 up 1 down 2 left 3 to right) <br> 2,//scrolling step <br> 200,//container visual width <br> 64,//container visual height <br> 50, the smaller the value of the//timer, the faster the scrolling speed (1000=1 seconds, recommended not less than) <br> 2000,//Intermittent pause time (0 for no pauses, 1000=1 seconds) <br> 1000,//start time waiting (0 for not waiting, 1000=1 seconds) <br> 22//Intermittent rolling spacing (optional) <br>); }; function Marquee () {This.id=document.getelementbyid (arguments[0]); This. DIRECTION=ARGUMENTS[1]; This. STEP=ARGUMENTS[2]; This. WIDTH=ARGUMENTS[3]; This. HEIGHT=ARGUMENTS[4]; This. TIMER=ARGUMENTS[5]; This. WAITTIME=ARGUMENTS[6]; This. STOPTIME=ARGUMENTS[7]; if (Arguments[8]) {this. SCROLLSTEP=ARGUMENTS[8];} Else{this. Scrollstep=this. Direction>1?this. Width:this. Height;} This. Ctl=this. Startid=this. Stop=this. mouseover=0; This. Id.style.overflowx=this. Id.style.overflowy= "hidden"; This. Id.nowrap=true; This. Id.style.width=this. Width; This. Id.style.height=this. Height; This. Clientscroll=this. Direction>1?this. ID.scrollWidth:this. Id.scrollheight; This. Id.innerhtml+=this. id.innerhtml; This. Start (this,this. Timer,this. Waittime,this. StopTime); } marquee.prototype.start=function (Msobj,timer,waittime,stoptime) {msobj. Startid=function () {msobj. Scroll ();} Msobj. Continue=function () {if (msobj). Mouseover==1) {settimeout (msobj). Continue,waittime);} Else{clearinterval (msobj. Timerid); Msobj. Ctl=msobj. Stop=0; Msobj. Timerid=setinterval (msobj. Startid,timer);} } msobj. Pause=function () {msobj. Stop=1; Clearinterval (msobj. Timerid); SetTimeout (msobj. Continue,waittime);} Msobj. Begin=function () {msobj. Timerid=setinterval (msobj. Startid,timer); Msobj. Id.onmouseover=function () {msobj. Mouseover=1; Clearinterval (msobj. Timerid);} Msobj. Id.onmouseout=function () {msobj. mouseover=0; if (msobj. stop==0) {clearinterval (msobj). Timerid); Msobj. Timerid=setinterval (msobj. Startid,timer);} } settimeout (Msobj. Begin,stoptime); } marquee.prototype.scroll=function () {switch (this. Direction) {case 0:this. Ctl+=this. Step; if (this. Ctl>=this. Scrollstep&&this. waittime>0) {this. Id.scrolltop+=this. Scrollstep+this. Step-this.ctl; This. Pause (); return;} Else{if (this. Id.scrolltop>=this. Clientscroll) this. Id.sCrolltop-=this. Clientscroll; This. Id.scrolltop+=this. Step;} Break Case 1:this. Ctl+=this. Step; if (this. Ctl>=this. Scrollstep&&this. waittime>0) {this. Id.scrolltop-=this. Scrollstep+this. Step-this.ctl; This. Pause (); return;} Else{if (this. id.scrolltop<=0) this. Id.scrolltop+=this. Clientscroll; This. Id.scrolltop-=this. Step;} Break Case 2:this. Ctl+=this. Step; if (this. Ctl>=this. Scrollstep&&this. waittime>0) {this. Id.scrollleft+=this. Scrollstep+this. Step-this.ctl; This. Pause (); return;} Else{if (this. Id.scrollleft>=this. Clientscroll) this. Id.scrollleft-=this. Clientscroll; This. Id.scrollleft+=this. Step;} Break Case 3:this. Ctl+=this. Step; if (this. Ctl>=this. Scrollstep&&this. waittime>0) {this. Id.scrollleft-=this. Scrollstep+this. Step-this.ctl; This. Pause (); return;} Else{if (this. id.scrollleft<=0) this. Id.scrollleft+=this. Clientscroll; ThiS.id.scrollleft-=this. Step;} Break } </script> <p> </p> <p> </p> <p> </p> </body> </pt Ml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.