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脚本代码完成跳转

在标签里执行代码

直接插入这句代码就可以

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

转载: https://www.cnblogs.com/du892294464/p/6835277.html

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值