<html>
<head>
<meta charset="utf8">
<script type="text/javascript">
var c=10
var t
function timedCount()
{
document.getElementById('txt').value=c
c=c-1
if(c==1)
{
window.location.href="http://www.baidu.com"
}
t=setTimeout("timedCount()",1000)
}
window.onload=timedCount;
</script>
</head>
<body>
<form>
<input type="button" value="开始计时!" onClick="timedCount()">
<input type="text" id="txt">
</form>
<p>请点击上面的按钮。输入框会从 0 开始一直进行计时。</p>
</body>
</html>