Simple Example of page latency jump using HTML/JS/PHP, js latency

Source: Internet
Author: User

Simple Example of page latency jump using HTML/JS/PHP, js latency

WEB development often encounters page Jump or delayed jump requirements. It is necessary to master various page Jump methods.

The following is my summary of how to implement redirection using three methods: HTML, JS, and PHP. The example is to jump to the index. php page three seconds later.

1. HTML method:

Add the <meta> label to the HEAD

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

2. JS redirect Control Method

A. Add link directly to Location

<script type="text/javascript">  setTimeout("window.location=('index.php'",3000);</script>

B. Location. href Mode

<script type="text/javascript">  setTimeout("window.location.href='index.php'",3000);</script>

C. Location. assign Method

<script type="text/javascript">  setTimeout("window.location.assign('index.php')",3000);</script>

D. Location. replace method (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. JS historical record go (n) mode (n indicates the number of forward steps of the historical record relative to the current page, n indicates that the previous page is returned)

<script type="text/javascript">  window.history.go(n);</script>

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

<script type="text/javascript">  window.history.go(‘index.php');</script>

In G. JS window. open mode, you can open a new window to redirect. (Its second attribute is an optional target option with a value such as frame id/_ blank. The third option is a specific setting option for the new pop-up window, including height/width)

<script type="text/javascript">  setTimeout("window.open('index.php',target,args)",3000);</script>

3. PHP scripts control the Redirect mode and rewrite the HTTP header information to redirect

A. header refresh mode:

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

B. header location method:

sleep(3);Header(“location:index.php”);

Note that this method will cause the current page to be inaccessible. That is, if you are currently in register. the php page is linked to login. login. the php page is redirected in the header location mode, and the page will be directed from register. the php page waits for three seconds to jump to the index. php does not enter login. php page, because the header location will redirect the page.

If any error occurs, please correct it. Thank you.

The above simple example of implementing page latency jump using HTML, JS, and PHP is all the content shared by Alibaba Cloud. I hope you can provide a reference and support for the customer's house.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.