大家看下跨浏览器滚动代码!
大家看下 下面的 滚动代码代码 找了半天 没找到哪里错了 但是 就是不显示 大家帮忙找找 谢谢了···程序代码:
<script language="javascript"> var info = "欢迎您"; var pop1 = 0; //阶段一中取出的字符数初始值 var pop2 = 0; //阶段三中隐藏的字符数初始值 var space = 0; //初始空格 var speed = 200; //滚动的速度 function scroll1(){ if(pop1<info.length){ //进入第一阶段 pop1 += 1; text1.innerText = info.substring(0,pop1); setTimeout("scroll1()",speed); }else{ pop1 = 0; setTimeout("scroll2()",speed); } } function scroll2(){ if(text1.offsetWidth<d.clientWidth){ space += 1; strspace = ""; for(var i=0; i<space; i++){ strspace += " "; text1.innerText = info + strspace; setTimeout("scroll2()",speed); } }else{ //进入第三阶段 d.style.textAlign = "left"; space = 0; setTimeout("scroll3()",speed); } } function scroll3(){ if(pop2<info.length){ pop2 += 1; text1.innerText = info.substring(pop2,info.length); setTimeout("scroll3()",speed); }else{ d.style.textAlign = "right"; pop2 = 0; setTimeout("scroll1()",speed); } } </script> <div id="d" style="width:500px;height:80px;position:relative;text-align:right;border:1px #00F solid;"> <span id="text1" ></span> </div>