zoukankan      html  css  js  c++  java
  • 页面跳转的两种实现方法

    利用<meta>实现

    参考代码
    1. <!DOCTYPE html>
    2. <htmllang="en">
    3. <head>
    4. <metacharset="UTF-8">
    5. <metahttp-equiv="refresh"content="10;url=http://www.baidu.com">
    6. <!--http-equiv实现页面与http挂钩,content内容设置延时的时间和要跳转的目的链接地址-->
    7. <title>JavaScriptDialog</title>
    8. </head>
    9. <bodystyle="text-align: center;">
    10. <h2>meta实现页面跳转</h2>
    11. <hr/>
    12. <span>实现代码</span>
    13. <mark>&lt;meta http-equiv="refresh" content="10;url=http://www.baidu.com"&gt;</mark>
    14. <script>
    15. </script>
    16. </body>
    17. </html>
     
    利用定时器实现
    参考代码
    1. <h2>定时器实现页面跳转</h2>
    2. <small>结合location的replace方法实现不能返回的跳转</small>
    3. <hr/>
    4. <b>
    5. <mark>10秒后跳转到百度首页</mark>
    6. </b>
    7. <br/>
    8. <timeid="ShowTime"></time>
    9. <script>
    10. setTimeout("window.location.replace('http://www.baidu.com')",10000);
    11. //注意此处使用replace方法,因此当跳转到目的链接之后是通过浏览历史或者前进、后退按钮返回
    12. //此处直接写执行的代码,因此需要用冒号括起来
    13. //*延时10s后跳转到baidu
    14. setInterval(function test(){
    15. var time = document.getElementById('ShowTime');
    16. time.innerText =newDate().toLocaleTimeString();
    17. },1000);
    18. //显示当前时间
    19. //执行代码写成函数,无需用冒号括起来,并且更规范些
    20. </script>
     





    从零到现在,一路走来,感谢众多无私的知识分享者,我愿意为你们接下一棒!
  • 相关阅读:
    关于C#登录三层
    SQL 语句关于分页的写法
    C# 如何去掉button按钮的边框线
    20151220
    继承
    对象的旅行
    多态
    封装
    OO大原则
    javascript
  • 原文地址:https://www.cnblogs.com/Jener/p/5938908.html
Copyright © 2011-2022 走看看