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

供大家参考,也欢迎大家提供更好地方案

<!DOCTYPE html>
<html>
 <head>
  <title>浏览器对象</title>  
  <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>   
 </head>
 <body>
  <!--先编写好网页布局-->
  <h1>操作成功</h1><br/>
  <span id="count"></span>秒后回到主页
  <a href="javascript:GoBack();">返回</a>
  <script type="text/javascript">  
 
   //获取显示秒数的元素,通过定时器来更改秒数。
  var num=5;
  setTimeout("startCount()",1000) ;
  function startCount() {
    document.getElementById('count').innerHTML=num;
    num=num-1;
    if(num==0){
        clearTimeout(i);
        window.open("http://www.imooc.com","_self");
    }
    var i=setTimeout("startCount()",1000) ;}
   //通过window的location和history对象来控制网页的跳转。
  function GoBack(){
      window.history.go(window.location.href);
  }
 </script> 
</body>
</html>


正在回答

1 回答

<script type="text/javascript">  

   //获取显示秒数的元素,通过定时器来更改秒数。

    var num = document.getElementById("time").innerHTML;

    function change(){

        num--;

        document.getElementById("time").innerHTML=num;

        if(num==0){

            location.assign("www.imooc.com");

        }

    }

    setInterval("change()",1000);

   //通过window的location和history对象来控制网页的跳转。

   function back(){

       window.history.back();

   }

 </script> 


0 回复 有任何疑惑可以回复我~
#1

橡皮dog 提问者

非常感谢!
2016-07-18 回复 有任何疑惑可以回复我~

举报

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

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

进入课程

供大家参考,也欢迎大家提供更好地方案

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信