Page refresh, js refresh current page

Source: Internet
Author: User

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

Related Article

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.