<!DOCTYPE?html>
<html>
?<head>
??<title>瀏覽器對象</title>
??<meta?http-equiv="Content-Type"?content="text/html;?charset=gkb"/>
?</head>
?<body>
??<!--先編寫好網(wǎng)頁布局-->
??<h2>操作成功</h2>
??<p><strong?id="sd">5</strong>秒后回到主頁?<a?href="javascript:back()">返回</a></p>
??<script?type="text/javascript">
???//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
????var?num?=?5?;
????function?startCount(){
????????num--;
????????document.getElementById("sd").innerHtml?=?num;
????????setTimeout("startCount()",1000);
????????if(num==0){
????????????window.location.assign("http://www.baidu.com");
????????}
????}
startCount();
????function?back(){
????????window.history.go(-1);
????}
???//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
?</script>
</body>
</html>
2017-12-20
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <h2>操作成功</h2>
? <p><strong id="sd">5</strong>秒后回到主頁 <a href="javascript:back()">返回</a></p>
?
? <script type="text/javascript">
?
? ?//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? ? var sd = document.getElementById("sd");
? ? var num = 5 ;
? ? function startCount(){
? ? ? ? num--;
? ? ? ? sd.innerHTML = num;
? ? ? ? setTimeout("startCount()",1000);
?
? ? ? ? if(num==0){
? ? ? ? ? ? window.location.assign("http://www.baidu.com");
? ? ? ? }
? ? }
? ? setTimeout("startCount()",1000);
?
? ? function back(){
? ? ? ? window.history.go(-1);
? ? }
?
?
? ?//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
?
?</script>
</body>
</html>