參考代碼,可正確運(yùn)行
<!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對(duì)象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>? ?
?</head>
?<body>
? <!--先編寫(xiě)好網(wǎng)頁(yè)布局-->
? <h3>操作成功</h3>
? <p><span id="second"></span>
? 秒后回到主頁(yè) <a href="#" onclick="goback()">返回</a>
? </p>
??
?
? <script type="text/javascript">??
? ?//獲取顯示秒數(shù)的元素,通過(guò)定時(shí)器來(lái)更改秒數(shù)。
? ?var num=5;
? ?function change(){
? ? ? ?if(num==0){
? ? ? ? ? ?clearTimeout(i);
? ? ? ? ? ?location.assign("http://idcbgp.cn");
? ? ? ?}
? ? ? ?else{
? ? ? document.getElementById("second").innerText=num;
? ? ? ?num--;
? ? ? ?var i=setTimeout(change,1000);
? ? ? ?}
? ?}
? ?//通過(guò)window的location和history對(duì)象來(lái)控制網(wǎng)頁(yè)的跳轉(zhuǎn)。
? ?function goback(){
? ? ? ?if(history.length>0){
? ? ? ? ? ? window.history.go(-1);
? ? ? ?}
? ? ? ?
? ?}
? ?change();
?</script>?
</body>
</html>
2019-10-14
change()函數(shù)沒(méi)有調(diào)用,就可以自動(dòng)執(zhí)行嗎?
2019-10-07
docuElementById("second").innerText=num;后面的innerText是什么意思。
為什么換成innerHTML也能執(zhí)行。
2019-10-07
docuElementById.("seconfd").innerText=num;后面的innerText什么意思
為什么換成innerHTML也能執(zhí)行
2019-08-28
nice