///pc/img/blank.gif" width="12" height="8">当前位置:///default.htm" class="under">亿度网络 -> ///pc/index.htm" class="under">网页制作教程 -> JavaScript实例
///pc/homepage/javascript/sample/img/bule.gif" width="207" height="13"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/js.gif" width="186" height="20"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
    跑 马 灯 效 果 ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
    ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  
效 果 演 示 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">

 

请看屏幕底下的状态栏!

 

   
 
源代码如下 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">



这段程序放在<head>与</head>之间

   
源程序讲解: ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
  ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  

function scroll(seed)
定义一个函数scroll,带有一个参数seed。
{ var m1 = "欢 迎 光 临"
var m2 = "洪 恩 在 线 电 脑 乐 园"
声明两个字符串型变量。
var msg=m1+" "+m2;
声明一个字符串型变量,值为以上两个字符串的和。
var out = " ";
声明一个变量,值为一个空格。
var c = 1;
声明一个变量,赋初值为1。
if (seed > 100)
{ seed--;
这是一个条件语句,当seed大于100时,seed递减。
var cmd="scroll(" + seed + ")";
声明一个变量,值为每次循环的结果。
timerTwo=window.setTimeout(cmd,100);
}
每100毫秒,执行一次cmd。
else if (seed <= 100 && seed > 0)
当seed大于0且小于100时,执行以下循环。
{ for (c=0 ; c < seed ; c++)
{ out+=" "; }
out+=msg;
seed--;
当c小于seed的值时,c递加,out的值为空格+msg的值,每次seed减1,即字的位置向前移。
var cmd="scroll(" + seed + ")";
声明一个变量,值为每次循环的结果。
window.status=out;
在状态栏显示out的值。
timerTwo=window.setTimeout(cmd,100); }
每100毫秒,执行一次cmd。
else if (seed <= 0)
{ if (-seed < msg.length)
{ out+=msg.substring(-seed,msg.length);
seed--;
当seed的值小于等于0时,在状态栏上显示除移出状态栏,剩下的字符,seed继续递减。
var cmd="scroll(" + seed + ")";
window.status=out;
timerTwo=window.setTimeout(cmd,100); }
在状态栏显示out的值,每100毫秒,执行一次cmd。
else { window.status=" ";
timerTwo=window.setTimeout("scroll(100)",7); } } }
当状态栏上没有字符时,重新开始调用scroll函数。
timerONE=window.setTimeout('scroll(100)',50); 窗口开始装载时,第一次调用函数。


  ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
 

 

网页制作 网页设计 网站建设 网站设计 网站制作 做网站 做网页