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