<!DOCTYPE?html>
<html>
<head>
????<title>瀏覽器對象</title>
????<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"/>
</head>
<body>
<br?/>
<a?href="#target1">第一個錨點</a>
<a?name="target1"></a>
<br?/>
<!--先編寫好網(wǎng)頁布局-->
<h2>操作成功</h2>
<span?id="djs">5</span>秒后回到主頁?<a?href="javascript:"?onclick="window.history.back();">返回</a>
<script?type="text/javascript">
????????var?t?=?5;
????????function?cuttime(){
????????????document.getElementById('djs').innerHTML=t;
????????????t?=?t?-?1;
????????????setTimeout("cuttime()",1000);
????????????if(t==0){
????????????????window.location.replace("http://idcbgp.cn/");
????????????}
????????}
????????cuttime();
????//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
????//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
</script>
</body>
</html>
2020-08-02
修正后正常運(yùn)行的代碼:
<!DOCTYPE html>
<html>
<head>
? ? <title>瀏覽器對象</title>
? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<br />
<a href="#target1">第一個錨點</a>
<a name="target1"></a>
<br />
<!--先編寫好網(wǎng)頁布局-->
<h2>操作成功</h2>
<span id="djs">5</span>秒后回到主頁 <a href="javascript:" onclick="window.history.back();">返回</a>
<script type="text/javascript">
? ? ? ? var t = 5;
? ? ? ? function cuttime(){
? ? ? ? ? ? document.getElementById('djs').innerHTML=t;
? ? ? ? ? ? t = t - 1;
? ? ? ? ? ? var g = setTimeout("cuttime()",1000);
? ? ? ? ? ? if(t==0){
? ? ? ? ? ? ? ? clearTimeout(g);
? ? ? ? ? ? ? ? window.location.replace("http://idcbgp.cn/");
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? cuttime();
? ? //獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? ? //通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
</script>
</body>
</html>
2020-07-21