JS Page Refresh method

Source: Internet
Author: User

1.reload method that forces the browser to refresh the current page
Syntax: Location.reload ([Bforceget])
Parameters: Bforceget, optional parameter, default is false from the client cache to fetch the current page. True, gets the latest page from the server in Get mode, equivalent to the client clicking F5 ("Refresh")
Example: Window.location.reload ();

2.replace method, which replaces the currently cached item in history (client) by making a URL, so you cannot access the URL that has been replaced by "forward" and "back" after using the Replace method
Syntax: Location.replace (URL)
How to use: Location.reload () or history.go (0) to do
This method is similar to the client Point F5 Refresh page, so when the page method= "POST", a "page expiration" prompt appears.
Because of the security protection mechanism of the session.
When the Location.reload () method is called, the ASPX page is already present in the server's memory, so it must be IsPostback.
If there is such an application: the page needs to be reloaded, that is, the desired page can be re-created on the server and the expectation is not IsPostback.
Here, Location.replace () can complete this task. The Replace page is regenerated on the server each time.
Code: Location.replace (LOCATION.HREF);
To return and refresh the page:
Location.replace (Document.referrer);
Document.referrer//URL of previous page
Do not use History.go (-1), or history.back (), to go back and refresh the page, neither of these methods refreshes the page.

3. The page automatically refreshes the,<meta http-equiv= "Refresh" content= ">"
Description: Refreshes the page every 20 seconds

4. Page Auto Jump:<meta http-equiv= "Refresh" content= "20;url=https://www.baidu.com/" >
Description: Jump to https://www.baidu.com/in 20 seconds

JS Page Refresh method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.