Difference and application between location. Reload () and location. Replace ()
APP Server Browser go. netblog
Transferred from
Http://blog.csdn.net/fangxinggood/archive/2006/02/21/604916.aspx
First, we will introduce the syntax of the two methods:
ReloadMethod, which forces the browser to refresh the current page.
Syntax:Location. Reload ([Bforceget]) Parameters: Bforceget Optional parameter. The default value is false. The current page is retrieved from the client cache. True Get Method to retrieve the latest page from the server, which is equivalent to clicking F5 ("refresh") on the client ")
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.
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. Therefore, when the method of the page is "Post ","Webpage expired". 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 needReloadThis page, that is, we expect the page to be re-created on the server. 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)