php Jump

Implemented in PHP script code

 

 <? Php header ( "location: url address")?> For example <php header?? ( "Location: helloworld.php")> page will jump immediately because of the location header to redirect execution

   

Immediately jump

Header(‘Location: URL’);

PHP (server) sends a command to the browser Location, tells the browser, on should redirect URL.

 

grammar:

Header () can not be any output content before the function.

 

Header () function behind the code will execute as usual:

Therefore, after the jump to terminate execution of the current script immediately, consistent with conventional navigation logic!

Delay Jump (such as after a successful landing time will have to wait a few seconds, then jump to another page)

<? php header ( "Refresh: seconds; url = address")?> e.g. <php header ( "Refresh: 3 ; url = helloworld.php")??> jump is executed after 3 seconds 
? <php sleep after the jump is executed: ( "url address location")> called sleep () method, the effect is x seconds header; (3)?

 

Tips Jump

 

Header ( 'Refresh: TIME; URL = target URL');

 

Refresh response to this instruction, it is after N seconds, the refresh to the specified target URL.

 

At this point, it will pause for three seconds on the current URL request. Jump After completing prompted by the display output.

 

 

Since the show is an ordinary page, style tips, you can easily customize!

 

 

grammar:

Code () after the Header will perform, so after handling operations associated with the jump, the script should be off DIE!

 

 

 

Js script code implemented in


1.window.location.href method

<script type="text/javascript">

  window.location.href="helloworld.php"          

</script>

  Use js approach to implementing delayed jump

<script type="text/javascript">

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

</script>

2.window.location.assign delaying jump as above

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

</script>

3.window.location.replace method (for the new page replaces the current page will not be saved in your history, all you can not use the browser back to the original page)

<script type="text/javascript">

  window.location.replace("helloworld.php");

</script>

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

<script type="text/javascript">

  window.open("index.php",_blank,width=300px);

</script>

Using HTML script code completion Jump

Executing code <head> tag

This code can be inserted directly into

<meta http-equiv="refresh" content="3;url='helloworld.php'"> 

Guess you like

Origin www.cnblogs.com/mmzz3322/p/10958565.html