為什么幾秒的時間不顯示
<html>
?<head>
? <title>瀏覽器對象</title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> ??
?</head>
?<body>
? <!--先編寫好網(wǎng)頁布局-->
? ? <h1>操作成功</h1>
? ? <span id='hehe'> </span>秒后回到主頁<a href="#" onclick="window.history.back()">返回</a>?
? ? <script type="text/javascript"> ?
? ? var num=5;
? ? function yanshi()
{
? ?document.getElementById('hehe').innerHTML=num;
? ?//獲取顯示秒數(shù)的元素,通過定時器來更改秒數(shù)。
? ? num--;
? ?//通過window的location和history對象來控制網(wǎng)頁的跳轉(zhuǎn)。
? ?if(num==0)
? ? {
? ? ? ?window.location.assign("http://idcbgp.cn/u/2966672/courses");
? ? }
? ? else{
? ? ? ? setTimeout(yanshi(),1000);
? ? ? ? }
}
?</script> ??
</body>
</html>
2016-04-14
你少寫了<span id="hehe">num<span>