ASP.NET中网页倒计时代码

来源:互联网 发布:未来社交网络 编辑:程序博客网 时间:2024/05/21 11:09

打开一个网页,上面显示5秒钟以后跳转到其他网页,每过一秒,它就会改变(4秒钟以后跳转,3秒钟以后跳转。。。)

<!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>
<title>Demo</title>
<script type="text/javascript">
var intervalID = 0;
var leftSeconds = 5;
function beginTimer()
{
loopTimerId = setInterval( timerStep, 1000 );
}
function timerStep()
{
if( leftSeconds > 1 )
{
leftSeconds --;
document.getElementById( "spTest" ).innerHTML = leftSeconds.toString() + "秒钟以后跳转到其他网页";
}
else
{
clearInterval( intervalID );
window.location.href = "newPage.aspx";
}
}
</script>
</head>
<body onload="beginTimer()">
<div>
<span id="spTest">5秒钟以后跳转到其他网页</span>
</div>
</body>
</html>

 

原创粉丝点击