Difference between location. reload and location. replace
Reload method, which forces the browser to refresh the current page.
Syntax: location. reload ([bForceGet])
Parameter: bForceGet. An optional parameter. The default value is false. The current page is retrieved from the client cache. If it is true, the latest page is retrieved from the server in GET mode, it 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)
Parameter: 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: location. replace (location. href)
========================================================== ========================================================== ==========
ReplaceBy specifyingURLReplace the current cached project in the history (client). Therefore, after the replace method is used, you cannot access the replaced project by "Forward" or "backward ".URL.
ReloadMethod, which forces the browser to refresh the current page
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.