A simple example _php instance of page delay jump implemented by html/js/php mode

Source: Internet
Author: User
Tags php script

Web development often encounter page jump or delay jump demand, master a variety of page jump way is very necessary.

The following is my summary of useful html/js/php three types of methods to achieve the jump, examples are three seconds after the jump to the index.php page.

1,html Method:

Add <meta> tag to head

<meta http-equiv= "Refresh" content= "3;url= ' index.php '" >

2,js Control Jump Method

A.location Direct plus Link way

<script type= "Text/javascript" >

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

</script>

B.location.href Way

<script type= "Text/javascript" >

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

</script>

C.location.assign Way

<script type= "Text/javascript" >

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

</script>

D.location.replace Mode (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 History Go (n) Way ( n Indicates the number of forward steps relative to the current page for the history record,n is a negative number to return to the previous page)

<script type= "Text/javascript" >

window.history.go (n);

</script>

F.js History go (URL) Way (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>

G.js window.open Way, by opening a new window, to achieve the jump. (The second property is the optional target option, the value can be frame Id/_blank , and the third option is the specific setting options for the new pop-up window, including height/width , etc.)

<script type= "Text/javascript" >

settimeout ("window.open (' index.php ', Target,args)", 3000);

</script>

3,php script control Jump Way, by overwriting HTTP header information to jump

A.header Refresh mode:

Header ("Refresh:3;url= ' index.php '");

B. Header location mode:

Sleep (3);

Header ("location:index.php");

Note that this can cause the current page to be inaccessible. Where currently register.php page is linked to login.php page,login.php page Header location mode jump, the page will be directly from the register.php page wait three seconds to jump to index.php, will not enter the login.php the page because header location redirects the page.

If there is a mistake, please correct me, thank you.

The above article uses the html/js/php way to realize the page delay to jump the simple example is the small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.

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.