Reload method, which forces the browser to refresh the current page.
Syntax: location. reload ([bForceGet]) parameter: bForceGet; optional parameter. The default value is false. The current page is retrieved from the client cache. True, the GET method is used to obtain the latest page from the server, which is equivalent to clicking F5 ("refresh") on the client ")
Replace method. This method replaces the items currently cached in the History (client) by specifying the URL. Therefore, after using the replace method, you cannot access the replaced URL by "Forward" or "backward.
Syntax: location. replace (URL)
When refresh the page in practice, we usually use location. reload () or history. go (0. This method is like refreshing the page by pressing F5 on the client. When the method = "post" is displayed, the prompt "webpage expired" appears. This is because of the security protection mechanism of the Session. It can be thought of: when the location. reload () method is called, The aspx page already exists in the server memory, so it must be IsPostback. If there is such an application: we need to re-load the page, that is, we expect the page to be re-created on the server, and we expect it to be Not IsPostback. Here, location. replace () can complete this task. The page to be replaced is generated on the server every time.
You can write like this: location. replace (location. href );
Return to and refresh the page:
Location. replace (document. referrer );
Document. referrer // the URL of the previous page
Do not use history. go (-1) or history. back (); to return and refresh the page. These two methods do not refresh the page.
Appendix:
How to refresh the page with Javascript:
1 history. go (0)
2 location. reload ()
3 location = location
4 location. assign (location)
5 document.exe cCommand ('refresh ')
6 window. navigate (location)
7 location. replace (location)
8 document. URL = location. href
How to automatically refresh the page:
1. Automatically refresh the page: Add the following code to the <Meta http-equiv = "refresh" content = "20">
20 indicates refreshing the page every 20 seconds.
2. automatic page Jump: Add the following code to the <Meta http-equiv = "refresh" content = "20; url = http://www.wyxg.com">
20 means jump to the http://www.wyxg.com page every 20 seconds
3. Automatically refresh js version on the page
<Script language = "JavaScript">
Function myrefresh ()
{
Window. location. reload ();
}
SetTimeout ('myrefresh () ', 1000); // refresh once per second
</Script>
JS refresh framework script statement
// How to refresh the page containing the framework
<Script language = JavaScript>
Parent. location. reload ();
</Script>
// Refresh the parent window in the Child Window
<Script language = JavaScript>
Self. opener. location. reload ();
</Script>
(Or <a href = "javascript: opener. location. reload ()"> refresh </a>)
// How to refresh the page of another framework
<Script language = JavaScript>
Parent. Another FrameID. location. reload ();
</Script>
If you want to refresh the window when closing the window or refresh the window when opening the window, you can call the following statement in <body>.
<Body onload = "opener. location. reload ()"> refresh when opening a window
<Body onUnload = "opener. location. reload ()"> refresh when disabled
<Script language = "javascript">
Zookeeper opener.doc ument. location. reload ()
</Script>