Page refresh, js refresh current page
1. 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. True, GET the latest page from the server in GET mode, which is equivalent to clicking F5 ("refresh") on the client ")
Example: window. location. reload ();
2. replace method. This method replaces the items currently cached in the History (client) by specifying a URL. Therefore, after using the replace method, you cannot access the replaced URL through "Forward" or "backward ".
Syntax: location. replace (URL)
Usage: location. reload () or history. go (0)
This method is similar to refreshing the page by clicking F5 on the client. Therefore, when method = "post" is displayed, the message "webpage expired" appears.
Because of the security protection mechanism of the Session.
When the location. reload () method is called, The aspx page already exists in the server memory, so it must be IsPostback.
If such an application is available, the page needs to be re-loaded. That is to say, the page is expected to be re-created on the server and Not IsPostback is expected.
Here, location. replace () can complete this task. The page to be replaced is generated on the server every time.
Code: location. replace (location. href );
Return to and refresh the page:
Location. replace (document. referrer );
Document. referrer // the URL of the previous page
Do not use history. go (-1) or history. back (); to return and refresh the page. These two methods do not refresh the page.
3. The page is automatically refreshed. <Meta http-equiv = "refresh" content = "20">
Note: The page is refreshed every 20 seconds.
4. automatic page Jump: <Meta http-equiv = "refresh" content = "20; url = https://www.baidu.com/">
Note: Jump to https://www.baidu.com/in 20 seconds