php中实现页面跳转的几种方式

亲测,not复制粘贴

PHP中实现页面跳转有一下几种方式,看了几个人写的不是很条理,自己整理一下

在PHP脚本代码中实现

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

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

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

在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‘"> 
时间: 2024-08-05 19:30:09

php中实现页面跳转的几种方式的相关文章

web项目中实现页面跳转的两种方式

<a href="javascript:"></a>跳转在网页本身,URL不改变 <a href="#"></a> 跳转在网页本身,URL 改变 java web项目中实现页面跳转的主要方式有两种:第一种,<% response.sendRedirect("index.jsp");%>第二种<jsp:forward page="index.jsp"/>我做

php页面跳转的几种方式

@: PHP页面跳转的三种方式 第一种方式:header() header()函数的主要功能是将HTTP协议标头(header)输出到浏览器. 语法: void header ( string $string [, bool $replace = true [, int $http_response_code ]] ) 可选参数replace指明是替换前一条类似标头还是添加一条相同类型的标头,默认为替换. 第二个可选参数http_response_code强制将HTTP相应代码设为指定值. he

JavaScript实现页面跳转的五种方式

JavaScript实现页面跳转的五种方式 第一种:<script type="text/javascript" language="javascript"> window.location.href="login.jsp?backurl="+window.location.href;</script> 第二种:<script type="text/javascript" language=&qu

实现前端页面跳转的几种方式

实现前端页面跳转的几种方式 推荐使用 <script language='javascript'> document.location = 'http://mail.qq.com/domain/longtimenosee.cc' </script> 相关阅读 http://www.jb51.net/article/25403.htm http://my.oschina.net/ososchina/blog/340854

iOS中的视图跳转的三种方式(代码跳转,根据桥跳转,按钮跳转)

#import "ViewController.h" #import "SecondViewController.h" @interface ViewController () @property (retain, nonatomic) IBOutlet UITextField *textField; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // D

js实现页面跳转的两种方式

CreateTime--2017年8月24日08:13:52Author:Marydon 方式一: window.location.href = url 说明:我们常用来在js中实现页面跳转的方法,使用get方式发送请求,传参有限 更多介绍,见文章:js操作当前窗口 方式二: 通过POST请求实现页面跳转 /** * 发送POST请求跳转到指定页面 * @param URL * 跳转路径 * @param PARAMS * 参数:格式-JSON对象 */ function httpPost(UR

js中获取页面元素节点的几种方式

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title></title> <!-- 使ie以IE8的模式运行 --> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" > <scr

js实现页面跳转的几种方式

第一种: <script language="javascript" type="text/javascript"> window.location.href="xx.jsp?backurl="+window.location.href; </script> 另外一种: <script language="javascript"> alert("返回"); window.

PHP 页面跳转的三种方式

第一种方式:header() header()函数的主要功能是将HTTP协议标头(header)输出到浏览器. 语法: void header ( string $string [, bool $replace = true [, int $http_response_code ]] ) 可选参数replace指明是替换前一条类似标头还是添加一条相同类型的标头,默认为替换. 第二个可选参数http_response_code强制将HTTP相应代码设为指定值. header函数中Location类