Return to previous page and Refresh page method

Source: Internet
Author: User

Original address: http://www.zixuephp.com/html/javascript/2014_09/1642.html

PHP implements 3 effective ways to return to previous page functionality

Header (Location: The path to your previous page); Note that there is no output before this function

Header (Location:.getenv ("Http_referer")); Return to its invocation page

echo "<script>alert (' Write anything '); History.go ( -1);</script>";

JS Reload page, refresh locally, return to previous page

The code is as follows Copy Code

<a href= "Javascript:history.go ( -1)" > Back </a>
<a href= "Javascript:location.reload ()" > Reload page, local refresh </a>
<a href= "Javascript:history.go ( -1); Location.reload ()" > Back to previous Reload page, local refresh </a>

Return to the first two pages and refresh the JS code should be how to write.


JS method

The code is as follows Copy Code
<a href= "#" onclick= "Self.location=document.referrer;" > Back </a>

How the ASP automatically returns and refreshes:

The code is as follows Copy Code
Response. Write ("<script language=javascript>self.location=document.referrer;</script>")

Typically used to submit an action to a page and then return to the previous page and refresh!


PHP practices

The code is as follows Copy Code

echo "<script>alert (' exit succeeded! '); Location.href= ' ". $_server[" Http_referer "]." '; </script> ";

Set the delete success to return to the previous page and refresh

The code is as follows Copy Code

if ($query)

{

$page = "listrenwu.php";

<!---this way will not refresh and will only be returned as-is

echo "<script>alert (' deletion succeeded '); History.go ( -1) </script>";

<!--//set to return to the previous page after successful deletion and refresh-->-->

echo "<script>alert (' delete succeeded '); window.location =" ". $page." "; </script> ";

}

Return to previous page and Refresh page method

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.