如图所示样子:
制作一个跳转提示页面:
要求:
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">返回</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>