如图所示样子:

制作一个跳转提示页面:
要求:
1. 如果打开该页面后,如果不做任何操作则5秒后自动跳转到一个新的地址,如百度主页。
2. 如果点击“返回”按钮则返回前一个页面
<!DOCTYPE html> <html> <head> <title>浏览器对象</title> <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> </head> <body> <!--先编写好网页布局--> <div><h1>操作成功</h1></div> <div><a id ="p1">5</a>后回到主页<a href="http://www.bAIdu.com" rel="external nofollow" >返回</a></div> <script type="text/JavaScript"> //获取显示秒数的元素,通过定时器来更改秒数。 var num = 100; function downTime(){ document.getElementById('p1').innerHTML=num; if(num>0){ num--; }else{ window.location = "http://www.baidu.com"; } setTimeout("downTime()",1000); } //通过window的location和history对象来控制网页的跳转。 downTime(); </script> </body> </html>
PS:下面看下JavaScript五秒自动跳转到新页面
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>五秒跳页五秒关闭</title>
<script type="text/javascript">
function countDown(secs,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>秒后自动跳转到//www.freexyz.cn/
<script type="text/javascript">countDown(5,'//www.freexyz.cn');</script>
</body>
</html>

