打字机效果文字

<html>
<head>

<script type="text/javascript">
message="最好的学习方法,是学习实例。-www.W3School.com.cn"
pos=0
maxlength=message.length+1

function writemsg()
{
if (pos<maxlength)
{
txt=message.substring(pos,0)
document.forms[0].msgfield.value=txt
pos++
timer=setTimeout("writemsg()", 50)
}
}
function stoptimer()
{
clearTimeout(timer)
}
</script>
</head>

<body onload="writemsg()" onunload="stoptimer()">
<form>
<input id="msgfield" size="65">
</form>
</body>
</html>

你可能感兴趣的:(打字机效果文字)