我的時間跳的不準??!求助熱心網友!哈哈!
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?</head>
?<body>
? <!--先編寫好網頁布局-->
? <div>
? ? ? <h2>操作成功</h2>
? ? ?<input type="text" id="txt" style="border:none; width:8px;"/>秒后返回到主頁
? </div>
? <script type="text/javascript">
? ? var num=5;
function numCount(){
document.getElementById('txt').value=num;
num=num-1;
}
setInterval("numCount()",1000);
? ? function a(){
window.open('http://www.xianlaiwan.cn','_parent');
}
setInterval("a()",5000);
?</script>?
</body>
</html>
2018-10-02
<!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="javascript:back();">返回</a>
??
??
?
? <script type="text/javascript"> ?
? ? var num=document.getElementById("second").innerHTML;
? ?//獲取顯示秒數的元素,通過定時器來更改秒數。
??
? ? function count()
? ? {
? ? ? ? num--;
? ? ? ? document.getElementById("second").innerHTML=num;
? ? ? ? if(num==0)
? ? ? ? {
? ? ? ? ? ? location.assign("www.xianlaiwan.cn");
? ? ? ? }
? ? }
? ? setInterval("count()",1000);
? ?//通過window的location和history對象來控制網頁的跳轉。
? ? function back()
? ? {
? ? ? ?window.history.back();
? ?}
? ?
?</script>?
</body>
</html>