本文實例講述了JS實現狀態欄跑馬燈文字效果代碼。分享給大家供大家參考,具體如下:
這款狀態欄跑馬燈,文字跑動的定義在數組內,自己可修改內容。現在的IE8貌似不兼容,有缺憾的代碼,歡迎JS愛好者修正,修正請發回一份。狀態欄為效果顯示區。
運行效果截圖如下:
在線演示地址如下:
http://demo.jb51.net/js/2015/js-ztlpmd-txt-style-codes/
具體代碼如下:
<HTML> <HEAD> <TITLE>間隔狀態欄跑馬燈</TITLE> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <SCRIPT language=JavaScript> <!-- function scrollit(seed) { var m1 = "HI:你 好! "; var m2 = "歡迎訪問網站"; var m3 = "請 多 提 意 見,謝 謝!"; var m4 = "E-MAIL:"; var m5 = "/"; var msg=m1+m2+m3+m4+m5; var out = " "; var c = 1; if (seed > 100) { seed--; cmd="scrollit("+seed+")"; timerTwo=window.setTimeout(cmd,100); } else if (seed <= 100 && seed > 0) { for (c=0 ; c < seed ; c++) { out+=" "; } out+=msg; seed--; window.status=out; cmd="scrollit("+seed+")"; timerTwo=window.setTimeout(cmd,100); } else if (seed <= 0) { if (-seed < msg.length) { out+=msg.substring(-seed,msg.length); seed--; window.status=out; cmd="scrollit("+seed+")"; timerTwo=window.setTimeout(cmd,100); } else { window.status=" "; timerTwo=window.setTimeout("scrollit(100)",75); } } } //--> </SCRIPT> <META content="MSHTML 6.00.2900.2963" name=GENERATOR> </HEAD> <BODY bgColor=#fef4d9 onload=scrollit(100)> </BODY> </HTML>
希望本文所述對大家JavaScript程序設計有所幫助。