为了账号安全,请及时绑定邮箱和手机立即绑定

mark

<!DOCTYPE html>
<html>
 <head>
  <title>浏览器对象</title>  
  <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>   
 </head>
 <body>
  <!--先编写好网页布局-->
  <h3>操作成功</h3>
  <b id="num">5</b>秒后回到主页 <a href="#" onlcik="back()">返回</a>
 
  <script type="text/javascript">  
  var num = parseInt(document.getElementById("num").innerHTML);

   function countdown(){
           num = num-1;
   		if(num<1){
   			window.location.href="http://www.imooc.com";
   			clearIntervar(i)
   		}
   		else{
   			document.getElementById("num").innerHTML=num;	
   		}
   }
   var i=setInterval("countdown()",1000);
   //获取显示秒数的元素,通过定时器来更改秒数。
    function back(){
    window.history.back();
  }
   //通过window的location和history对象来控制网页的跳转。
   
 </script> 
</body>
</html>


正在回答

举报

0/150
提交
取消
JavaScript进阶篇
  • 参与学习       468357    人
  • 解答问题       21893    个

本课程从如何插入JS代码开始,带您进入网页动态交互世界

进入课程
意见反馈 帮助中心 APP下载
官方微信