神操作之实现PHP跳转

互联网 20-5-6

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

在PHP脚本代码中实现

<?php header("location:url地址") ?>

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

<?php header("Refresh:秒数;url=地址") ?>

在js脚本代码中实现

1.window.location.href方法

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

使用js方法实现延迟跳转

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

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

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

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

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

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

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

使用HTML脚本代码完成跳转

在<head>标签里执行代码

直接插入这句代码就可以

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

花式实现相关跳转,你值得拥有

推荐学习:PHP

以上就是神操作之实现PHP跳转的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
标签: PHP
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:PHP Swoole 基本使用

相关资讯