<!DOCTYPE html> <html> <head> <title>浏览器对象</title> <meta http-equiv="Content-Type" content="text/html; charset=gkb"/> </head> <body> <h4>操作成功</h4> <p> <b id="select">5</b>自动返回主页<a href="javaScript:goBack();">返回</a> </p> <script type="text/javascript"> var sel=document.getElementById("select"); var i=5; function set(){ sel.innerHTML=i; i--; setTimeout("set()",1000); if(i==1){ window.location.href="http://www.imooc.com"; } } function goBack(){ window.history.back(); } </script> </body> </html>
因为根本没有调用set函数啊,我加上一个调用就行了