复制代码 代码如下: 这是一个动态JavaScript文字显示的例子 <BR>var POSITION = 50; <BR>var DELAY = 150; <BR>var MESSAGE = "这是一个动态JavaScript文字显示的例子"; <BR>function bannerObject(){ <BR>this.msg = MESSAGE; <BR>this.out = " "; <BR>this.pos = POSITION; <BR>this.delay = DELAY; <BR>this.i = 0; <BR>this.reset = clearMessage; <BR>} <BR> <BR>function clearMessage(){ <BR>this.pos = POSITION; <BR>} <BR>var scroll = new bannerObject(); <BR>function scroller(){ <BR>scroll.out += " "; <BR>if(scroll.pos>0) <BR>for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++){ <BR>scroll.out +=" " ; <BR>} <BR>if (scroll.pos>= 0) <BR>scroll.out += scroll.msg; <BR>else <BR>scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length); <BR>document.noticeForm.notice.value = scroll.out; <BR>scroll.out = " "; <BR>scroll.pos--; <BR>scroll.pos--; <BR>if (scroll.pos < -(scroll.msg.length)) { <BR>scroll.reset(); <BR>} <BR>window.setTimeout("scroller()", scroll.delay); <BR>} <BR> 在状态栏滚动文字 复制代码 代码如下: 这是一个跑马灯效果的JavaScript文档-在状态栏 <BR>var msg = "这是一个跑马灯效果的JavaScript文档"; <BR>var interval = 100; <BR>var spacelen = 120; <BR>var space10 = " "; <BR>var seq = 0; <BR>function Scroll() { <BR>len = msg.length; <BR>window.status = msg.substring(0, seq + 1); <BR>seq++; <BR>if (seq >= len) { <BR>seq = spacelen; <BR>window.setTimeout("Scroll2();", interval); <BR>} <BR>else <BR>window.setTimeout("Scroll();", interval); <BR>} <BR>function Scroll2() { <BR>var out = ""; <BR>for (i = 1; i <= spacelen / space10.length; i++) <BR>out +=space10; <BR>out = out + msg; <BR>len = out.length; <BR>window.status = out.substring(seq, len); <BR>seq++; <BR>if (seq >= len) { seq = 0; }; <BR>window.setTimeout("Scroll2();", interval); <BR>} <BR>Scroll(); <BR>