/*
timeId=window.setTimeout("method()",1000); window.clearTimeout(timeId);定时执行
timeId=window.setInterval("method()",1000); window.clearInterval(timeId);循环执行
*/
<script language="javascript" type="text/javascript">
var tipId;
var sTime;
function show()
{
sTime = 5;
tipId = window.setInterval("my()",1000);
}
function my()
{
if(sTime<0)
{
window.clearInterval(tipId);
document.getElementById("dvMsg").innerText="时间到...";
}
else
{
document.getElementById("dvTime").innerText=sTime;
sTime--;
}
}
</script>
</head>
<body>
<input type="button" οnclick="show()" value="启动" />
<div style=" color:Red; font-size:200px"><div id="dvTime"></div></div>
<div id="dvMsg"><a href="http://www.baidu.com/">百度</a></div>
</body>