reload method, this method forces the browser to refresh the current page. At grammar: Location.reload ([BFORCEGET])
Parameter: BFORCEGET, optional parameter, default to False, take the current page from the client cache. If true, the latest page is fetched from the server in GET mode, which is equivalent to the client clicking F5 ("Refresh")
replace method. This method replaces the item currently cached in the history (client) by specifying the URL, so After using the replace method, you cannot access the replaced URL through "forward" and "back".
Syntax: location.replace(URL)
In actual application, when refreshing the page, we usually use: location.reload() or history.go(0) to do it. Because this approach is like the client clicking F5 to refresh the page, so when the page's method="post" is used, a "webpage expired" prompt will appear. That's because of Session's security protection mechanism. You can think 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 reload the page, which means we expect the page to be re-created on the server side, and we expect Not IsPostback. Here, location.replace() can accomplish this task. The replaced page is regenerated on the server every time.
You can write like this: location.replace(location.href);
Return and refresh the page:
location.replace(document.referrer);
document.referrer //URL of the previous page
Don’t use history .go(-1), or history.back(); to return and refresh the page. These two methods will not refresh the page.
Attachment:
Several ways to refresh the page in Javascript:
1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('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 93f0f5c25f18dab9d176bd4f6de5d30e In the area
cbc445b94b07fca83f8f029a735ab635
20 refers to refreshing the page every 20 seconds.
2. The page automatically jumps: add the following code to the 93f0f5c25f18dab9d176bd4f6de5d30e area
b740c70c237487cba3cb8c1a60aa3903
The 20th finger will jump to http://www.php after 20 seconds. cn page
3. The page automatically refreshes the js version
<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>
JS refresh frame script statement
//How to refresh the page containing the frame using
a2bbbb160e7164ddd930eed2a74569d1
parent.location.reload( );
2cacc6d41bbb37262a98f745aa00fbf0
//The child window refreshes the parent window
a2bbbb160e7164ddd930eed2a74569d1
self.opener.location.reload();
2cacc6d41bbb37262a98f745aa00fbf0
( Or ="javascript:opener.location.reload()">Refresh5db79b134e9f6b82c0b36e0489ee08ed )
//How to refresh the page of another frame using
a2bbbb160e7164ddd930eed2a74569d1
parent.Another FrameID.location. reload();
2cacc6d41bbb37262a98f745aa00fbf0
If you want to refresh when the window is closed or you want to refresh when the window is opened, just call the following statement in 6c04bd5ca3fcae76e30b72ad730ca86d.
a7a591df2625d01ed15b6b4328865a6d Refresh when the window is open
fc87e241137c5c6656c7ddd89ab240df Refresh when the window is closed
7b0dfeba8bc22e3cf89f15b10076be31
window.opener.document.location.reload()
2cacc6d41bbb37262a98f745aa00fbf0
For more summary of several JS methods to refresh the current page, please pay attention to the PHP Chinese website for related articles!