<!DOCTYPE html><html>?<head>? <title>瀏覽器對象</title> ?? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ???</head>?<body>? <!--先編寫好網頁布局-->??? <p> 操作成功</p>? <p id="p3" >5</p>? <p> 秒后回到主頁</p>? <input type='button' value="返回" onclik="javascript:bak();"/>?????? <script type="text/javascript"> ?? ? ?setInterval("op()",1000);? ?//獲取顯示秒數的元素,通過定時器來更改秒數。? ? ? setInterval("op()",1000);? ? ?function op(){? ? ? ? ?var s=5;? ? ? ? ?if(s==0){? ? ? ? ? ?location.replace("http://www.baidu.com");? ? ??? ? ? ? ?}? ? ? ? ?s--;? ? ? ? ?document.getElementById("p3").innerHTML=s;? ? ? ? ?? ? ?}? ? ?function bak(){? ? ? ?history.back();? ? ?}? ?//通過window的location和history對象來控制網頁的跳轉。? ??</script>?</body></html>
為什么我的代碼跳到4就不繼續了
北極的大熊
2017-01-19 15:42:37