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>标签里执行代码,直接插入这句代码就可以

  • 相关阅读:
    关于在调用JAVAFX相关包时遇到Access restriction: The type 'Application' is not API (restriction on required library)的解决方法
    JS 获取随机颜色值
    JS jQuery 点击页面漂浮出文字
    JQ 获取浏览器窗口宽高
    JQ 操作css
    JQ 遍历--(祖先,后代,同胞,过滤)
    JQ DOM元素 创建 添加 删除
    jQuery 效果
    3
    webpack 打包CSS 引入图片
  • 原文地址:https://www.cnblogs.com/wsybky/p/8575810.html
Copyright © 2011-2022 走看看