Home  >  Article  >  Web Front-end  >  The specific implementation of using js to refresh the current page and retain parameters_javascript skills

The specific implementation of using js to refresh the current page and retain parameters_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:07:471527browse

After the website has a certain amount of traffic, it needs to find ways to improve the stickiness of the website. World Buyer Network recently plans to develop a set of foreign trade tools, which are some commonly used tools, such as world time query http://www.buyerinfo.biz /tools/global-time/, hscode query, exchange rate query and conversion, etc. Some of them have been completed. Please take a look and provide more comments. There is also js refresh, which I am not very good at, so I recorded the

reload method, which forces the browser to refresh the current page.
Syntax: location.reload([bForceGet])
Parameters: bForceGet, optional parameter, default is false, retrieve the current page from the client cache. true, then use the GET method to fetch the latest page from the server, which is equivalent to the client clicking F5 ("Refresh")

replace method, which replaces the current cache in the history by specifying the URL (client) project, 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 pressing 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.

can be written like this: location.replace(location.href);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn