当前位置: 代码迷 >> ASP.NET >> 一段源码 求详细解释,该如何处理
  详细解决方案

一段源码 求详细解释,该如何处理

热度:8745   发布时间:2013-02-25 00:00:00.0
一段源码 求详细解释
<script language="JavaScript">
<!-- 
if (document.all){
Cols=6;
Cl=24;//Space's are included so real length is 48!
Cs=10;
Ts=10;
Tc='#008800';
Tc1='#00ff00';
MnS=20;
MxS=30;
I=Cs;
Sp=new Array();S=new Array();Y=new Array();
C=new Array();M=new Array();B=new Array();
RC=new Array();E=new Array();Tcc=new Array(0,1);
document.write("<div id='Container' style='position:absolute;top:0;left:-"+Cs+"'>");
document.write("<div style='position:relative'>");
for(i=0; i < Cols; i++){
S[i]=I+=Cs;
document.write("<div id='A' style='position:absolute;top:0;font-family:Arial;font-size:"
+Ts+"px;left:"+S[i]+";width:"+Ts+"px;height:0px;color:"+Tc+";visibility:hidden'></div>");
}
document.write("</div></div>");

for(j=0; j < Cols; j++){
RC[j]=1+Math.round(Math.random()*Cl);  
Y[j]=0;
Sp[j]=Math.round(MnS+Math.random()*MxS); 
for(i=0; i < RC[j]; i++){
 B[i]='';
 C[i]=Math.round(Math.random()*1)+' ';
 M[j]=B[0]+=C[i];
 }
}
function Cycle(){
Container.style.top=window.document.body.scrollTop;
for (i=0; i < Cols; i++){
var r = Math.floor(Math.random()*Tcc.length);
E[i] = '<font color='+Tc1+'>'+Tcc[r]+'</font>';
Y[i]+=Sp[i];

if (Y[i] > window.document.body.clientHeight){
 for(i2=0; i2 < Cols; i2++){
 RC[i2]=1+Math.round(Math.random()*Cl);  
 for(i3=0; i3 < RC[i2]; i3++){
 B[i3]='';
 C[i3]=Math.round(Math.random()*1)+' ';
 C[Math.floor(Math.random()*i2)]=' '+' ';
 M[i]=B[0]+=C[i3];
 Y[i]=-Ts*M[i].length/1.5;
 A[i].style.visibility='visible';
 }
 Sp[i]=Math.round(MnS+Math.random()*MxS);
 }
}
A[i].style.top=Y[i];
A[i].innerHTML=M[i]+' '+E[i]+' ';
}
setTimeout('Cycle()',20)
}
Cycle();
}
// -->
</script>

------解决方案--------------------------------------------------------
<script language="JavaScript">
<!--
if (document.all)//通过这句判断是IE还是其它浏览器,这里表示IE浏览器
{
Cols=6;
Cl=24;//Space's are included so real length is 48!
Cs=10;
Ts=10;
Tc='#008800';
Tc1='#00ff00';
MnS=20;
MxS=30;
I=Cs;
Sp=new Array();S=new Array();Y=new Array();//创建几个Array内置对象
C=new Array();M=new Array();B=new Array();
RC=new Array();E=new Array();Tcc=new Array(0,1);
document.write("<div id='Container' style='position:absolute;top:0;left:-"+Cs+"'>");
document.write("<div style='position:relative'>");//动态输出控件并显示出来
for(i=0; i < Cols; i++){
S[i]=I+=Cs;
document.write("<div id='A' style='position:absolute;top:0;font-family:Arial;font-size:"
+Ts+"px;left:"+S[i]+";width:"+Ts+"px;height:0px;color:"+Tc+";visibility:hidden'></div>");
}
document.write("</div></div>");

for(j=0; j < Cols; j++){
RC[j]=1+Math.round(Math.random()*Cl); //Math.Random是一个内置函数,用于返回0到1间的随机数 
Y[j]=0;
Sp[j]=Math.round(MnS+Math.random()*MxS);
for(i=0; i < RC[j]; i++){
 B[i]='';
 C[i]=Math.round(Math.random()*1)+' ';//Math.Round也是一个内置函数,用于取整.
 M[j]=B[0]+=C[i];
 }
}
function Cycle(){
Container.style.top=window.document.body.scrollTop;//设置Container的y坐标为当前页面滚动条滚动的距离.
for (i=0; i < Cols; i++){
var r = Math.floor(Math.random()*Tcc.length);//Math.Floor用于返回最近的整数
E[i] = '<font color='+Tc1+'>'+Tcc[r]+'</font>';
Y[i]+=Sp[i];

if (Y[i] > window.document.body.clientHeight){
 for(i2=0; i2 < Cols; i2++){
  相关解决方案