Javascript Imitation Lyrics Smart Scrolling code _ Text effects

Source: Internet
Author: User
Make sure the viewer can see the text and continue scrolling up and down.
<ptml> <pead> <title> text scrolling </title> <style type= "Text/css" > #infozone {font-size:12px; Color: #aa6; overflow:hidden;width:98px;height:20px;} #infozone Div{height:20px;line-height:20px;white-space:nowrap;overflow:hidden;} </style> <script type= "Text/javascript" > var tc; Window.onload=function () {var O=document.getelementbyid (' Infozone '); HScroll (o); Window.setinterval (function () {window.cleartimeout (TC); o.firstchild.style.marginleft= ' 0px '; Scrollup (o,20,0);}, 8000); The function Scrollup (o,d,c) {if (d==c) {var t=o.firstchild.clonenode (true); O.removechild (O.firstchild); O.appendchild (t); t.style.margintop=o.firstchild.style.margintop= ' 0px '; HScroll (o); } else{Ch=false;var s=3,c=c+s,l= (c>=d?c-d:0); o.firstchild.style.margintop=-c+l+ ' px '; Window.settimeout (function () {Scrollup (o,d,c-l)},50); } function HScroll (o) {var w1=o.firstchild.offsetwidth,w2=o.offsetwidth; if (W1&LT;=W2) return; Tc=window.settimeout (function () {HS (O,W1-W2, 0,w1-w2)},3500); function HS (o,d,c,p) {C++;var t= (c>0?-c:c); o.firstchild.style.marginleft=t+ ' px '; if (C==d) {if (d==0) {tc=window.settimeout (function () {HS (O,P,0,P)},2500);} else Tc=window.settimeout (function () {HS (O,0,-P,P)},3500);} else Tc=window.settimeout (function () {HS (O,D,C,P)},5); } </script> </pead> <body> <div id= "Infozone" ><div> Blue and White porcelain (jay) </div><div> Life has you (wood age) </div><div> mythology (Sun Nan, han) </div> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
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.