Home > Backend Development > PHP Tutorial > A simple example of using HTML/JS/PHP to implement delayed page jump_php example

A simple example of using HTML/JS/PHP to implement delayed page jump_php example

WBOY
Release: 2016-08-04 08:56:59
Original
917 people have browsed it

In WEB development, we often encounter the need for page jumps or delayed jumps. It is very necessary to master various page jump methods.

The following is a summary of how I can use HTML/JS/PHP to implement jumps. The examples are all about jumping to the index.php page after three seconds.

1, HTML method:

Add tag in HEAD

<meta http-equiv=”refresh” content=”3;url='index.php'” >
Copy after login

2, JS control jump method

A.Location direct link method

<script type="text/javascript">

  setTimeout("window.location=('index.php'",3000);

</script>
Copy after login

B.Location.hrefmethod

<script type="text/javascript">

  setTimeout("window.location.href='index.php'",3000);

</script>
Copy after login

C.Location.assignmethod

<script type="text/javascript">

  setTimeout("window.location.assign('index.php')",3000);

</script>
Copy after login

D.Location.replacemethod (note that the page is "replaced" and will not be queried in the browser's history)

<script type="text/javascript">

  Widdow.location.replace(‘index.php');

</script>
Copy after login

E.JSHistorygo(n)method (n represents the progress of history relative to the current page, n is a negative number to return to the previous page)

<script type="text/javascript">

  window.history.go(n);

</script>
Copy after login

F.JSHistorygo(url)method (note that url must be in the history, otherwise the page will not jump)

<script type="text/javascript">

  window.history.go(‘index.php');

</script>
Copy after login

G.JS window.open method enables jump by opening a new window. (The second attribute is an optional target option, the value can be frame id/_blank, etc., and the third option is the specific setting option of the new pop-up window, including height/width, etc.)

<script type="text/javascript">

  setTimeout("window.open('index.php',target,args)",3000);

</script>
Copy after login

3. The PHP script controls the jump method and jumps by rewriting the HTTP header information

A.header refresh method:

Header(“refresh:3;url='index.php'”);
Copy after login

B. header location method:

sleep(3);

Header(“location:index.php”);
Copy after login

Please note that this method will make it impossible to enter the current page. That is, if the current register.php page is linked to the login.php page, and the login.php method is used to jump within the header location, the page will jump from register. The php page will directly wait for three seconds to jump to index.php and will not enter the login.php page. This is because the header location will redirect the page.

If there are any errors, please correct them, thank you.

The above simple example of using HTML/JS/PHP to implement page delay jump is all the content shared by the editor. I hope it can give you a reference, and I hope you will support Script Home.

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