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

(跳转提示页面)这代码以后用得上

<!DOCTYPE html>

<html>

 <head>

  <title>浏览器对象</title>  

  <meta http-equiv="Content-Type" content="text/html; charset=gkb"/>   

 </head>

 <body>

  <!--先编写好网页布局-->

  <p>操作成功</p>

  <span id="countTime"></span>&nbsp;<a href='javascript:goBack()'>返回</a>

 

  <script type="text/javascript">  

    var second = 5;

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

    var message = document.getElementById("countTime");

    function clock()

    {

        if(second==0)

        {

            goTo();

        }

        else

        {

            message.innerHTML = second-- + "秒后回到主页";

            window.setTimeout(clock,1000);

        }

    }

    clock();

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

   function goTo()

   {

        window.location.href = "http://www.baidu.com";

   }

   function goBack()

   {

    //   window.history.Back();

        window.location.href = "http://www.sina.com";

   }

 </script> 

</body>

</html>


正在回答

1 回答

收藏了,赞

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

举报

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

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

进入课程

(跳转提示页面)这代码以后用得上

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号