頁面跳轉(zhuǎn),為啥沒效果
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對(duì)象</title> ?
? <meta http-equiv="Content-Type" content="text/html"; charset="UTF-8"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <span id="second">5</span>
? <span> 秒后回到主頁</span>
? <input type="button" value="返回" onclick="return()">
??
?
? <script type="text/javascript"> ?
?
? ?//獲取顯示秒數(shù)的元素,通過定時(shí)器來更改秒數(shù)。
? ? var numb=document.getElementById("second").innerHTML;
? ? function count(){
? ? ? ? numb--;
? ? ? ? document.getElementById("second").innerHTML=numb;
? ? ? ? if(numb==0)
? ? ? ? ? {location.assign("idcbgp.cn");}
? ? }
? ? setInterval("count()",1000);
? ?//通過window的location和history對(duì)象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ?function return(){
? ? ? ?window.history.go(-1);
? ?}
? ?
?</script>?
</body>
</html>
2017-04-05
首先你的numb是通過document.getElementById("second").innerHTML獲得的,你又有個(gè)numb--,想讓它自減。。但是numb獲得的是一個(gè)字符串類型的數(shù)據(jù),它自減不了的
2017-04-05
<script type="text/javascript"> ?
? ? var num=document.getElementById("second").innerHTML;
? ?//獲取顯示秒數(shù)的元素,通過定時(shí)器來更改秒數(shù)。
??
? ? function count()
? ? {
? ? ? ? num--;
? ? ? ? document.getElementById("second").innerHTML=num;
? ? ? ? if(num==0)
? ? ? ? {
? ? ? ? ? ? location.assign("idcbgp.cn");
? ? ? ? }
? ? }
? ? setInterval("count()",1000);
? ?//通過window的location和history對(duì)象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ? function return()
? ? {
? ? ? ?window.history.return();
? ?}
2017-04-05
assign那里加http試一下