zoukankan      html  css  js  c++  java
  • PHP中实现页面跳转的方式(php跳转,js跳转,html跳转)

    PHP中实现页面跳转有以下几种方式

    在PHP脚本代码中实现

    header('location:main.php');

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

    header('Refresh:3;url=main.php');

    或者

    sleep(3);
    header('location:main.php');

    在js脚本代码中实现

    1.window.location.href方法

    <script>
        window.location.href = 'main.php';
    </script>

    使用js方法实现延迟跳转

    <script>
        setTimeout("window.location.href = 'main.php'",3000);
    </script>

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

    <script>
        window.location.assign = 'main.php';
    </script>

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

    <script>
        window.open('main.php','_blank','width=200px');
    </script>

    (如果被浏览器拦截,改为允许即可)

    使用HTML脚本代码完成跳转

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

    <html>
    <head>
        <meta http-equiv="refresh" content="3;url='main.php'">
    </head>
    </html>
  • 相关阅读:
    hdu2089 不要62 (数位dp)
    LightOJ 1140
    在n到m中 有多少个1 (数位dp)
    Frequent Subsets Problem 状态压缩 判断出现的次数
    LightOj 1215
    LightOJ 1197
    Spring 知识点提炼
    设计模式—访问者模式
    设计模式—模板模式
    设计模式—策略模式
  • 原文地址:https://www.cnblogs.com/chenyingying0/p/12972584.html
Copyright © 2011-2022 走看看