最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

神操作之实现PHP跳转

来源:动视网 责编:小采 时间:2020-11-03 12:31:43
文档

神操作之实现PHP跳转

神操作之实现PHP跳转:PHP中实现页面跳转有以下几种方式在PHP脚本代码中实现<php header("location:url地址") > 例如 <php header("location:helloworld.php")> 页面会立即跳转,因为header执行了location重
推荐度:
导读神操作之实现PHP跳转:PHP中实现页面跳转有以下几种方式在PHP脚本代码中实现<php header("location:url地址") > 例如 <php header("location:helloworld.php")> 页面会立即跳转,因为header执行了location重


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 header("location:url地址") > 例如 <php header("location:helloworld.php")> 页面会立即跳转,因为header执行了location重
推荐度:
标签: php 实现 跳转
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top