首页 > 代码库 > 打字机慢版

打字机慢版

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<script language="JavaScript">

function do_submit()
{
var count = 0;
var str=document.getElementById("shuru").value;
var num=parseInt(Math.random()*10)
//alert (num)
var timer = setInterval(function(){
document.getElementById("shuchu").value=http://www.mamicode.com/str.substring(0,count+num);
count++;
if(count >= str.length){
clearInterval(timer);
}
}, 1000);
}

</script>
<p>
<input name="" type="button" onClick="do_submit()" value="http://www.mamicode.com/提交" /></button>
<input value="" id="shuru"/>
</p>
<p>
<textarea name="textfeld" id="shuchu" cols="" rows="" readonly="readonly" ></textarea>
</p>
</body>
</html>

打字机慢版