以下代碼,時(shí)間到了就頁面變成空白。
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對(duì)象</title>?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <div>
????? <h2>操作成功</h2>
????? <p><span id="second">5</span>秒后回到主頁 </p>
????? <a href="http://idcbgp.cn/">或點(diǎn)擊此處立即前往</a>
????? <a href="javascript:back()">返回</a>
? </div>
?
?
? <script type="text/javascript">?
?var a=document.getElementById("second").innerHTML;
?function time(){
?a--;
?document.getElementById("second").innerHTML=a;
?switch(a){
???? case 0:
???? location.assign("http://idcbgp.cn/")
???? break;}
?}
setInterval("time()",1000);
?? //獲取顯示秒數(shù)的元素,通過定時(shí)器來更改秒數(shù)。
function back(){
??? window.history.back();
}
?? //通過window的location和history對(duì)象來控制網(wǎng)頁的跳轉(zhuǎn)。
??
?</script>
</body>
</html>
2018-08-24
地址形式錯(cuò)了,http后面少了個(gè)s
2018-08-01
window.location.assign("http://idcbgp.cn/");
試下這樣