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

    1、最常用的当然是在a标签里写链接,跳转页面,这个就不用说了

    2、使用js的window.loaction跳转页面

    <script>
        //使用href属性跳转
    location.href ='http://www.baidu.com';
        //使用assign()方法跳转
    location.assign('
    http://www.baidu.com');
        //使用replace()方法跳转
    location.replace('
    http://www.baidu.com');
       //只适用于IE
       window.navigate("
    http://www.baidu.com"); 
    </script>
    3、使用Html中<meta>标签来定义页面的元信息

      <!-- 5秒钟后跳转到指定页面 -->
      <meta http-equiv="refresh" content="5;url=http://www.baidu.com"/>
      <!-- 10秒钟后刷新页面,但不跳转 -->
      <meta http-equiv="refresh" content="10">
    4、定时器跳转页面

      setTimeout("javascript:location.href='hello.html'", 5000);
    5、返回上一页

      window.history.back(-1); 
      window.history.go(-1);
    6、打开新窗口
      window.open('http://www.baidu.com')
  • 相关阅读:
    第十次作业
    第九次作业总结
    第九次作业
    第八次作业总结
    第七次作业总结
    第六次总结
    第十二次作业总结
    第十一次作业总结
    第十次作业总结
    第九次作业总结
  • 原文地址:https://www.cnblogs.com/qiruoranbeginner/p/7495903.html
Copyright © 2011-2022 走看看