Home > Backend Development > PHP Problem > What are the methods to implement page jump in php

What are the methods to implement page jump in php

coldplay.xixi
Release: 2023-03-03 18:12:01
Original
3341 people have browsed it

php methods to implement page jumps are: 1. Implement the jump in the PHP script code; 2. Use the js method to implement the delayed jump; 3. Use the HTML script code to complete the jump.

What are the methods to implement page jump in php

php methods to implement page jump are:

1. Implement in PHP script code

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

Delayed jump (for example, after successful login, there will be a few seconds of waiting time, and then jump to other pages)

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

2. In the js script code Implementation

1.window.location.href method

<script type="text/javascript">
  window.location.href="helloworld.php"          
</script>
Copy after login

Use js method to implement delayed jump

<script type="text/javascript">
  setTimeout("window.location.href=&#39;helloworld.php&#39;",3000);
</script>
Copy after login

2.window.location.assign method Delayed jump The method is the same as above

<script type="text/javascript">window.location.assign("helloworld.php");
</script>
Copy after login

3.window.location.replace method (allowing the new page to replace the current page, it will not be saved in the history, so you cannot use the browser to return to the original page)

<script type="text/javascript">
  window.location.replace("helloworld.php");
</script>
Copy after login

4. The window.open method has three parameters, the first URL address. The second is the way to open a new page (such as new page _blank, _new, self jump _self), and the third is the way to open a new page, including style, location, etc.

<script type="text/javascript">
  window.open("index.php",_blank,width=300px);
</script>
Copy after login

3. Use HTML script code to complete the jump

Execute the code in the <head> tag

directly Just insert this code

<meta http-equiv="refresh" content="3;url=&#39;helloworld.php&#39;">
Copy after login

Related learning recommendations: php graphic tutorial

The above is the detailed content of What are the methods to implement page jump in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template