页面5秒后跳转
一、常见于404页面
<div class="demo">
<p><span>4</span><span>0</span><span>4</span></p>
<p>抱歉(´・ω・`),该页面不存在<span id="time" color="#FFF"> 15</span> 秒钟之后自动跳转</p>
<!--,如果不跳转,请点击下面链接 -->
<!-- <a href="http://www.baidu.com/">百度</a>-->
</div>
<script type="text/javascript">
function delayURL(url) {
var delay=document.getElementById("time").innerHTML;
if(delay>0){
delay--;
document.getElementById("time").innerHTML=delay;
}
else{
window.top.location.href=url;
}
setTimeout("delayURL('" + url + "')", 1000);
}
delayURL("http://www.baidu.com/");
</script>
(二)类似方法:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function countDown(secs,surl){
//alert(surl);
var jumpTo = document.getElementById('jumpTo');
jumpTo.innerHTML=secs;
if(--secs>0){
setTimeout("countDown("+secs+",'"+surl+"')",1000);
}
else{
location.href=surl;
}
}
</script>
</head>
<body><span id="jumpTo">5</span>秒后自动跳转到http://www.baidu.com/
<script type="text/javascript">countDown(5,'http://www.baidu.com/');</script>
</body>
</html>