zoukankan      html  css  js  c++  java
  • 用php实现跳转的几种方式

    来源:https://www.cnblogs.com/du892294464/p/6835277.html

    php实现页面跳转有几种方式:

    一、在php脚本中实现

    1  <?php  header("location:url地址") ?>   
    2 // <?php  header("location:helloworld.php")?> 页面会立即跳转,因为header执行了location重定向

      延迟跳转(比如登陆成功后会有几秒钟等待时间,然后跳转到了其他页面)

    1 <?php header("Refresh:秒数; url=地址") ?> 
    2 // <?php header("Refresh:3; url='helloworld.php' ")?> 会在3秒后执行跳转
    3 <?php sleep(3); header("location:url地址") ?>  
    4 // 调用了sleep()方法,效果也是x秒后执行跳转

    二、在js脚本代码中实现

      1. window.location.href 方法

    1 <script type="text/javascript">
    2     window.location.href="helloworld.php"          
    3 </script>

      使用js方法实现延迟跳转

    1 <script type="text/javascript">
    2     setTimeout("window.location.href='helloworld.php'",3000);
    3 </script>

      2. window.location.assign 方法,延迟跳转方法同上

    1 <script type="text/javascript">
    2     window.location.assign("helloworld.php");
    3 </script>

      3. window.location.replace方法,(让新页面替换掉当前页面,不会保存在历史记录里,所有不能使用浏览器后退到原页面了)

    1 <script type="text/javascript">
    2     window.location.replace("helloworld.php");
    3 </script>

      4.window.open方法,三个参数,第一个URL地址。第二个打开新页面方式(比如新页面_blank,_new,自身跳转_self),第三个是新页面的方式,包括样式,位置等。

    1 <script type="text/javascript">
    2     window.open("index.php",_blank,width=300px);
    3 </script>

    三、使用HTML脚本代码完成跳转

    1 <meta http-equiv="refresh" content="3;url='helloworld.php'"> 

      在<head>标签里执行代码,直接插入这句代码就可以

  • 相关阅读:
    理财-4
    “大锅”遇险记
    今日份灵感开发
    持续集成简介
    redis clusert分布式集群
    redis 哨兵
    redis 主从复制
    Redis新特性ACL安全策略
    redis 快照持久化RDB和AOF
    redis 基础常用命令
  • 原文地址:https://www.cnblogs.com/wsybky/p/8575810.html
Copyright © 2011-2022 走看看