用JavaScript编制跑马灯
#1 例1:在浏览器的状态行中从左至右用打字效果显示
<SCRIPT Language=″JavaScript″>
var T=″《电脑报》欢迎您!″;
var interval=250;
t=10;
function A()
{len=T.length;
window.status=T.substring(0,
t+1);
t++;
if(t>=len) {t=0};
window.setTimeout(″A();″,interval);}
</SCRIPT>
<BODY OnLoad=″A();″>
#1 例2:在网页中开设一个小窗口,在其中先用打字效果显示文本,再从左至右跑马
<SCRIPT Language=″JavaScript″>
var msg=″《电脑报》电子版欢迎您!″;
var interval=250;
var space10=″ ″;
var t=0;
function A1()
{document.tmForm,
tmText.value=msg.substring(0,t+1);
t++;t++;
if(t>=msg.length){t=0;
window.setTimeout(″A2();″,interval);}
else
window.setTimeout(″A1();″,interval);}
function A2(){
document.tmForm.tmText.value=msg.substring(t,msg.length)+space10+msg.su
bstring(0,msg.length);
t++;t++;
if (t>msg.length) {t=0};
window.setTimeout(″A2();″,interval);}
</SCRIPT>
<BODY OnLoad=″A1();″>
<CENTER><FORM Name=tmForm>
<INPUT type=Text Name=tmText Size=45>
</FORM></CENTER>