為什么實際是要到-3才跳轉(zhuǎn)頁面??????
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? <h2>操作成功<h2>
?<p>
? <span id=lol>5</span>秒后回到主頁 <a href="http://idcbgp.cn">返回<a>
?</p>
? <script type="text/javascript">
? ufo=document.getElementById("lol").innerHTML;
?function pb(){
? ? ?ufo--;
? ? ? document.getElementById("lol").innerHTML=ufo;
?if(ufo==0){
? ? location.assign("idcbgp.cn");
?}
?}
? ? ?setInterval("pb()",1000)
? ?//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? ?//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
?function back()
? ? {
? ? ? ?window.history.back();
? ?}
?</script>
</body>
</html>
2016-07-29
這樣就不會出現(xiàn)負數(shù)了。還有<a>改成<a href="#" onclick="back()">返回<a>
2016-07-26
ufo=document.getElementById("lol").innerHTML;這句話移到函數(shù)pb()內(nèi)部試試