[求助]麻烦各位看下这段
我不懂javascript,网上找的一段打字机效果代码,离我想要的效果有点差距,麻烦各位帮忙改下,谢谢!要求:运行后循环随机的输出typ0~typ8的内容...
<script type="text/javascript">
var current = 0
var x = 0
var speed = 70
var speed2 = 2000
function initArray(n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '
}
}
typ = new initArray(16);
typ[0]="406:green:00000";
typ[1]="409:green:11111";
typ[2]="384:green:22222";
typ[3]="413:green:33333";
typ[4]="371:green:44444";
typ[5]="373:green:55555";
typ[6]="379:green:66666";
typ[7]="406:green:77777";
typ[8]="380:green:88888";
function typewrite() {
var m = typ[current];
document.getElementById("typewriter").href = '/survey/report.html?rt=' + m.substring(0,m.indexOf(':'));
m = m.substring(m.indexOf(':') + 1);
document.getElementById("typewriter").style.color = m.substring(0,m.indexOf(':'));
m = m.substring(m.indexOf(':') + 1);
m = m.replace("&","and");
document.getElementById("typewriter").innerHTML = m.substring(0, x++) + "_";
if (x == m.length + 1) {
x = 0
current++
if (current > typ.length - 1) {
current = 0
}
setTimeout("typewrite()", speed2)
}
else {
setTimeout("typewrite()", speed)
}
}
//document.getElementById("tickertitle").innerHTML = "Latest: ";
/*document.getElementById("smHeadlines").style.padding = "10px";*/
typewrite()
</script>