Home > Web Front-end > JS Tutorial > Summary of common page jump methods in php_javascript skills

Summary of common page jump methods in php_javascript skills

WBOY
Release: 2016-05-16 16:03:50
Original
1114 people have browsed it

Sometimes user pages will jump when writing PHP. Here we have collected several good jump methods that can be used.

Using HTTP header information

That is, use PHP’s HEADER function. The function of the HEADER function in PHP is to issue control instructions to the browser that should be passed through the WEB server specified by the HTTP protocol, such as declaring the type of return information ("Context-type: xxx/xxx"), the attributes of the page ("No cache", "Expire"), etc.
The method to redirect to another page using HTTP header information is as follows:

Copy code The code is as follows:

if (isset($url))
{
Header("HTTP/1.1 303 See Other");
Header("Location: $url");
exit; //
}
?>

Marked with HTML

Use HTML tag, that is, use REFRESH tag of META, for example:

Copy code The code is as follows:




Copy code The code is as follows:

$url="http://www.jb51.net";
echo "";
?>

Use html features

Copy code The code is as follows:

echo "< meta http-equiv=\"Refresh\" content=\"number of seconds; url=jumped file or address\" > ";

Where: XX is the number of seconds, 0 means jump immediately. refresh means refresh. Url is the page to jump to.

Use script to implement

Copy code The code is as follows:

echo '<script>url="submit.php";window.location.href=url;</script>';

Another implementation using script

Use script to implement, the difference is the use of the open statement. And you can limit the original window to the parent window, child window or new window.

Copy code The code is as follows:

<script>url="submit.php";window.open('url,'','_self');</script>

Change '_self' to limit the jump to the original window, parent window, child window or new window. The seventh method: use PHP's own function to send header information

Copy code The code is as follows:

header("Location: Url");

The fastest and most powerful... But there is a problem that must be pointed out: if there is already html output before using this function, even if it is a space, then an error message will be displayed at the top of the page..

The above is the entire content of this article, I hope you all like it.

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template