php中实现页面跳转有几种方式 ?-PHP问题

资源魔 31 0

php中完成页面跳转有几种形式 ?

php中完成页面跳转的形式有:

正在PHP剧本代码中完成

<?php header("location:url地点") ?> 例如 <?php header("location:helloworld.php")?> 页面会立刻跳转,由于header执行了location重定向

1、提早跳转(比方登岸胜利后会有几秒钟期待工夫,而后跳转到了其余页面)

代码:

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

例如:

<?php   header("Refresh:3;url=helloworld.php")?>

会正在3秒后执行跳转

<?php sleep(3); header("location:url地点")?>

挪用了sleep()办法,成果也是x秒后执行跳转。

2、正在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>


3、应用HTML剧本代码实现跳转

正在<head>标签里执行代码

间接拔出这句代码就能够

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

保举教程:《PHP视频教程》

以上就是php中完成页面跳转有几种形式 ?的具体内容,更多请存眷资源魔其它相干文章!

标签: php php教程 php故障解决 php使用问题 页面跳转

抱歉,评论功能暂时关闭!