任務
第一步: 先編寫好網頁佈局,如下:
第二步: 獲取顯示秒數的元素,通過定時器來更改秒數。
第三步: 通過window的location和history對象來控制網頁的跳轉
__________________________________________________
<!DOCTYPE html>
<html>
<head>
<title>瀏覽器對象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
</head>
<body>
<!--先編寫好網頁佈局-->
<h2>操作成功</h2>
<h3 id="wait">5秒後回到主頁</h3>
<a href="javascript:back()">返回</a>
<script type="text/javascript">
var i=5;
//獲取顯示秒數的元素,通過定時器來更改秒數。
function Go(){
i-=1;
if (i == 0) {
window.location.assign("http://www.imooc.com");
}
}
setInterval("Go()",1000);
//通過window的location和history對象來控制網頁的跳轉。
function back(){
window.history.back();
}
</script>
</body>
</html>