終于解決了
<!DOCTYPE html>
<html>
<head>
<title>瀏覽器對象</title>
<meta http-equiv="Content-Type" content="text/html; charset=gkb" />
</head>
<body>
<!--先編寫好網(wǎng)頁布局-->
<h3>操作成功</h3>
<label id="second">5</label>
<span>秒后回到主頁</span>
<a href="http://idcbgp.cn" target="_self">返回</a>
<script type="text/javascript">
var time = 5;
function clock() {
//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
document.getElementById("second").innerHTML = time;
time = time - 1;
if(time==-1){
clearInterval(i);
window.location.href="http://idcbgp.cn";
}
}
i=setInterval(clock, 1000);
//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
</script>
</body>
</html>
2019-11-19