可以自动跳转到首页,也可以跳转到特定的链接。
<script language=javascript>
function countDown(secs,surl){
if(--secs>0){
setTimeout("countDown("+secs+",'"+'http://baidu.com'+surl+"')",1000);
}
else{
location.href="http://baidu.com";
}
}
</script>
<%@ page contentType="text/html; charset=utf-8" language="java"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<style type="text/css">
<!--
body{background: url(http://img.test.com/news/image/news/background.gif) repeat;font:12px "ËÎÌå", Arial;color:#333;margin:0;padding:0;}
div{margin:0;padding:0;border:0;}
.main0816{width:371px;margin:0 auto;margin-top:47px;}
.main0816 .logo{width:371px;height:67px;text-align:center;}
.mainbox{width:371px;margin:0 auto;}
.mainbox .title{width:371px;height:17px;background:url(http://img.test.com/news/image/news/boxtop.gif) no-repeat;}
.mainbox .content{width:365px;margin:0 auto;height:75px;padding-top:40px;border:1px solid #ccc;border-top:0px;background:#fff;}
.mainbox .content .text{width:280px;margin:0 auto;height:32px;line-height:32px;background:url(http://img.test.com/news/image/news/boxicon.gif) no-repeat;padding-left:50px;font-size:14px;font-weight:bold;}
-->
</style>
</head>
<script language=javascript>
function countDown(secs,surl){
if(--secs>0){
setTimeout("countDown("+secs+",'"+surl+"')",1000);
}
else{
location.href=surl;
}
}
</script>
<body>
<div class="main0816">
<div class="logo"><img src="http://js.test.com/homepage/logo/logo138x50.png" alt="" /></div>
<div class="mainbox">
<div class="title"></div>
<div class="content">
<div class="text">页面没有找到,3秒钟之后带您进入首页</div>
</div>
</div>
</div>
<script language=javascript>countDown(4,'/');</script>
</html>
效果如图所示: