倒計時結(jié)束后跳轉(zhuǎn)到慕課網(wǎng)主頁但顯示找不到文件,代碼哪里出了問題?
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? ? <h2>操作成功</h2>
? <span id="sec">5</span>秒后返回主頁<a href="idcbgp.cn" onclick="gb()">返回</a>
??
? <script type="text/javascript">??
? ?//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? ?var num=5;
? ?function second(){
? ? ? ?if(num==0){
? ? ? ? ? ?clearTimeout(i);
? ? ? ? ? ?window.location.assign("idcbgp.cn");
? ? ? ?}
? ? ? ?else{
? ? ? ? ? ?document.getElementById("sec").innerText=num;
? ? ? ? ? ?num--;
? ? ? ? ? ?var i=setTimeout("second()",1000);
? ? ? ?}
? ?}
? ?//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ?function gb(){
? ? window.history.go(-1);
? ?}
? ?second();
?</script>?
</body>
</html>
2020-02-29
window.location.assign("http://idcbgp.cn");
這樣就可以了