點擊返回的時候有用,但是計時的從5計時到-100,就是不跳轉,這可咋整
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <h1>操作成功</h1>
? <span id="second">5</span>
? <span>秒返回到主頁</span>
? <a href id="javascript:back()">返回</a>
?
? <script type="text/javascript">??
?
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
? ?var num=document.getElementById('second').innerHTML;
? ?function count() {
? ? ? ? num=num-1;
? ? ? ? document.getElementById("second").innerHTML=num;
? ? ? ? if(num==1)
? ? ? ? {
? ? ? ? ? ?windows.location.assign("http://idcbgp.cn/u/4178927/courses");
? ? ? ? }
? }
? ? ? ? setInterval("count()",1000);
? ?//通過window的location和history對象來控制網頁的跳轉。
? ?function back(){
? ? ? ?window.history.go(-1);
? ?}
? ?
?
? ?
?</script>?
</body>
</html>
2018-11-24
?window.location.assign("http://idcbgp.cn/u/4178927/courses");,window沒有s