Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of location.reload in js

Shulou Source: shulou.com Published: 2022-06-03 11:12:26 11月15日 Update

This article mainly introduces the use of location.reload in js, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Location.reload method

This method forces the browser to refresh the current page.

Syntax: location.reload ([bForceGet])

Parameter: bForceGet. Optional. Default is false. The current page is fetched from the client cache. If set to true, the latest page is fetched from the server in GET mode, which is equivalent to a client click on F5 ("Refresh")

The replace method, which replaces items in the current cache (client) by specifying URL, so after using the replace method, you cannot access the URL that has been replaced through "forward" and "backward".

Syntax: location.replace (URL)

Parameter: URL

Location.reload () is usually used

In practical application, when refreshing the page, we usually use: location.reload () or history.go (0) to do it. Because this is like a customer endpoint F5 refreshing the page, when the method= "post" of the page, there will be a "page out of date" prompt. That's because of Session's security mechanism.

As you can imagine: when the location.reload () method is called, the page already exists in the server memory, so it must be IsPostback.

If there is such an application: we need to reload the page, that is, we expect the page to be recreated on the server side, and we expect it to be NotIsPostback. For this, location.replace () can accomplish this task. Pages that are replace are regenerated on the server every time. You can write like this: location.replace (location.href)

Redirection uses herf and replace

Thank you for reading this article carefully. I hope the article "what is the use of location.reload in js" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Pages methods customers times articles services parameters clients caches syntax applications expectations security that is values tasks practices interests memory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Redmi vpn Shulou Technology OPPO Reno