Home  >  Article  >  Backend Development  >  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
WBOYOriginal
2016-08-04 08:56:59906browse

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 e8e496c15ba93d81f6ea4fe5f55a2244 tag in HEAD

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

2, JS control jump method

A.Location direct link method

<script type="text/javascript">

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

</script>

B.Location.hrefmethod

<script type="text/javascript">

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

</script>

C.Location.assignmethod

<script type="text/javascript">

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

</script>

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>

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>

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>

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>

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'”);

B. header location method:

sleep(3);

Header(“location:index.php”);

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.

Statement:
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