使网页延迟5秒钟跳转的asp代码如何编写

使网页延迟5秒钟跳转的asp代码如何编写

第1个回答  推荐于2016-05-26
可用以下三种方法之一实现网页定时跳转:

方法一:用纯ASP代码实现
dim nowtime
nowtime=NOW()
do while datediff("s",nowtime,NOW())<5
loop
reponse.redrect "要跳转的页面"

方法二:用JS实现
<script language="javascript" type="text/javascript">
setTimeout("javascript:location.href='要跳转的页面'", 5000);
</script>

方法三:在网页的<head>和</head>之间加上以下语句
<meta http-equiv="refresh" content="5;url=要跳转的页面">
第2个回答  2013-05-18
用HTML中的meta标记就行了。
<meta http-equiv="refresh" content="5;url=your_url">
第3个回答  2011-04-02
<html>
<head>
<script type="text/javascript">
<!--
var duration=2900;
var timer=null;
var endTime = new Date().getTime() + duration + 100;
function interval()
{
var n=(endTime-new Date().getTime())/1000;
if(n<0) return;
document.getElementById("timeout").innerHTML = n.toFixed(3);
setTimeout(interval, 10);
}
function stopJump()
{
clearTimeout(timer);
document.getElementById("jumphint").style.display = "none";
}
window.onload=function()
{
timer=setTimeout("window.location.href='http://www.baidu.com'", duration);
interval();
}
//-->
</script>

</head>
<body>

<h1>出错啦!!</h1>
对不起! 你所访问的页面出错或者不存在!<br />
<span id="jumphint">系统在 <span id="timeout">3.000</span> 秒后 将自动</span>跳转到 <a href="http://www.baidu.com">baidu首页</a><br />
</body>
</html>

参考资料:http://hi.baidu.com/mdslsh/blog/item/8ddda3feb6832d305c6008b4.html

本回答被网友采纳