不能自减啊,然后就不造怎么了
<body onload="count()"> 操作成功 <br> <span id="time">5</span>s后回到主页 <a href="javascript:back()">返回</a> <script type="text/javascript"> var num= document.getElementById("time").innerHTML; function count() { num--; document.getElementById("time").innerHTML=num; if(num==0){ location.assign("http://www.imooc.com/code/1633"); } } setInterval("count()",1000); function back(){ document.write(window.history.back()); } </script>
var num= document.getElementById("time").innerHTML; document.getElementById("time").innerHTML=num; setInterval("count()",1000); window.history.back();
第一、二句要用innerHTML而不是value;
第三句要么用这个,setTimeout的话请先载入count(),用onload之类的;
第四句,windows <==> window;