<!DOCTYPE?html>
<html>
?<head>
??<title>瀏覽器對象</title>??
??<meta?http-equiv="Content-Type"?content="text/html;?charset=gkb"/>???
?</head>
?<body>
??<!--先編寫好網(wǎng)頁布局-->
??<h2>操作成功</h2>
??<p><span?id="ctime"?>5</span>回到主頁<a?href="back()">返回<a/></p>
?
??<script?type="text/javascript">?
????var?index?=?window.location.host;
????var?num?=?document.getElementById("ctime").innerHTML;
????function?count(){
????????num?=?num?-?1;
????????document.getElementById("ctime").innerHTML=num;
????????if(num?==?0){
????????location.assign("idcbgp.cn")?;
????????}
????}//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
????setTimeout("count()",1000);
????function?back(){
????????window.history.back()
????}
???//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
???
?</script>?
</body>
</html>
2016-11-02
你要用setInterval() 同學(xué) setTimeout 只會觸發(fā)一次
2016-11-09
里面最后加一個setTimeout
2016-11-02
2016-11-02
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <p>操作成功</p></br>
? <span id="count">5</span>
? ? <p>秒后回到主頁
? ? ? ? <input type="button" value="返回" onclick="goback()">
? ? </p>
? ? </br>
?
? <script type="text/javascript"> ?
? ? var num=document.getElementById("count").innerHTML;
? ?//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? ? ?function startCount(){
? ? ? ? ?document.getElementById("count").innerHTML=num;
? ? ? ? ?num=num-1;
? ? ? ? ?if(num==0)
? ? ? ? ? ?location.assign("idcbgp.cn");
? ? ? }
? ?//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ? ? setInterval("startCount()",1000);
? ? ? function goback(){
? ? ? ? ? window.history.go(-1);
? ? ? }
? ? ??
?</script>?
? ??
</body>
</html>