Summary of page Jump methods in php development, php development page Jump
Page Jump may be triggered by clicking links or buttons, or automatically generated by the system. Automatic page Jump is often used in WEB development, and different jump methods can be used as needed, such as delayed jump after prompting operation information, this article summarizes several common page Jump methods in WEB development.
PHP header () function jump
PHP's header () function is very powerful. It also makes simple calls in page url jump. You can use header () to directly jump to the specified url page. In this case, the page Jump is 302 redirection:
$url = "http://www.bkjia.com/"; header( "Location: $url" );
We may encounter special jumps. For example, if the website has a page address for 301 redirection, you can configure rewrite on the web, but now I want to tell you, you can use the php header () function to perform 301 redirection. The Code is as follows:
// 301 jump header ("HTTP/1.1 301 Moved Permanently"); header ("Location: $ url ");
Meta settings jump
In the meta information in html, you can directly set the jump, and set the jump delay time and jump url, which are frequently applied. For example, after the payment is complete, the code is very simple to tell the user that the payment is successful and jump to the order page, add the following sentence to
<meta http-equiv="refresh" content="5;url=http://www.bkjia.com">
The code above indicates that the page automatically jumps to the http://www.bkjia.com after 5 seconds.
Javascript jump
Javascript jump is also very simple, just one sentence:
<script> window.location.href="http://www.bkjia.com"; </script>
Note: After the above Code is directly redirected, you cannot obtain a referer (also called a source) in the target page address. In the actual project, when a customer asks for a jump to bring the path (that is, the target webpage can get where the page is redirected), we can use javascript to simulate a click, then the jump satisfies the customer's needs.
<Script> // there is a path var aa = document. createElement ("a"); aa. setAttribute ("href", "http://www.bkjia.com"); var bodys = document. getElementsByTagName ("body") [0]; bodys. appendChild (aa); aa. click (); </script>
Of course, in actual development, we can integrate the following two methods into PHP to facilitate various jump needs.
The above is all the content of this article. I hope you will like it.