神操作之实现PHP跳转-php教程

资源魔 25 0

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'">

花式完成相干跳转,你值患上领有

保举学习:PHP

以上就是神操作之完成PHP跳转的具体内容,更多请存眷资源魔其它相干文章!

标签: php php开发教程 php开发资料 php开发自学

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