var clock=document.getElementById("txt")和clock()之间有一定联系吗,当i=clock.innerHTML时,时间没动,i=clock.innerHTML和clock.innerHTML=i有什么区别?
<!doctype html> <html> <head> <meta charset="utf-8"> <title>制作一个跳转提示页面</title> </head> <body> <p>操作成功</p> <p><span id="txt">5</span>秒后回到主页 <a href="javascript:GoBack();">返回</a></p> <script type="text/javascript"> var i=5; function clock(){ var clock=document.getElementById("txt"); i=i-1; clock.innerHTML=i; if(i==1){ location.href="http://www.imooc.com"; } setTimeout("clock()",1000); } setTimeout("clock()",1000); function GoBack(){ window.history.back(); } </script> </body> </html>