This article is a mirror article of machine translation, please click here to jump to the original article.

View: 9212|Reply: 0

[JavaScript] js page refresh Summary of the difference between locatio{filter}n.reload and locatio{filter}n.replace

[Copy link]
Posted on 2/17/2016 12:27:59 PM | | |

reload method, which forces the browser to refresh the current page.
Syntax: locatio{filter}n.reload([bForceGet])
Parameter: bForceGet, optional parameter, defaults to false, fetches the current page from the client cache. true, then the latest page is retrieved from the server in the GET method, which is equivalent to the client clicking F5 ("Refresh").

replace method, which replaces the item currently cached in history (client) by specifying a URL, so when using the replace method, you cannot access the replaced URL by "forward" and "backward".
Syntax: locatio{filter}n.replace(URL)
In practice, when refreshing the page, we usually use locatio{filter}n.reload() or history.go(0) to do it. Because this practice is like the client clicking F5 to refresh the page, when the page's method="post", a "page expired" prompt will appear. That's because of Session's security protection mechanism. You can think of it as when you call the locatio{filter}n.reload() method, the aspx page already exists in the server's 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 recreated on the server side, and we expect it to be not postbacked. Here, locatio{filter}n.replace() can do this. The replaced page is regenerated on the server side every time. You can write it like this: locatio{filter}n.replace(locatio{filter}n.href)



The replace function is exactly the same as locatio{filter}n's href attribute or assign function in setting the URL, but it removes the URL from the address list of the history object, making functions like go or back unnavigable.




Previous:Regarding the compatibility issue of SQL 2000 database attachment to SQL 2012
Next:C# webbrowser to determine whether the page is loaded
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com