A summary of several methods for JS refreshing the current page

Source: Internet
Author: User
Tags server memory

  This article is mainly to JS refresh the current page of several methods for a detailed summary of the introduction, the need for friends can come to the reference, I hope to help you.

Reload method that forces the browser to refresh the current page. Syntax: Location.reload ([Bforceget])                                                             &N Bsp                                   &NB Sp                         parameters: bforceget, optional parameters, default to False, from client cache Take the current page. True to get the latest page from the service, equivalent to the client-click F5 ("Refresh")   Replace method, which replaces the item currently cached in history (client) by specifying a URL, so after you use the Replace method, you cannot pass the "forward And back to access URLs that have been replaced. Syntax: Location.replace (URL)       In practical applications, when refreshing the page, we usually use: Location.reload () or history.go (0) to do. Because this practice is like the client point F5 Refresh the page, so the page method= "POST", will appear "page expiration" hint. That's because the session's security protection mechanism. It can be thought that when the Location.reload () method is invoked, the ASPX page already exists in the server memory, so it must be IsPostback. If this applies: we need to reload the page, which means we expect the page to be recreated on the server side, and we expect it to be not IsPostback. Here, L.Ocation.replace () can complete this task. The replaced pages are regenerated each time on the server side.   You can write this: Location.replace (LOCATION.HREF);   Return and Refresh page:   Location.replace (Document.referrer); Document.referrer//Previous page URL   do not use History.go (-1), or history.back (), to return and refresh the page, these two methods do not refresh the page.  : JavaScript Refresh page Several methods: 1    history.go (0)   2    location.reload ()   3    l ocation=location  4    location.assign (location)   5    document.execcommand (' Refresh ')   6    window.navigate (location)   7    location.replace (location)   8     Document. url=location.href    Automatic Refresh page method:   1. Page automatically refresh: Add the following code to the <head> area <meta http-equiv= "Refresh" content= > 20 means to refresh the page every 20 seconds.   2. Page Auto Jump: Add the following code to <head> area <meta http-equiv= "Refresh" content= "20;url=http://www.jb51.net" > 20 points to 20 seconds after the jump to the Http://www.jb51.net page   3. The page automatically refreshes the JS version code as follows: <script language= "JavaScript" > Function Myrefresh () {      window.location.reload (); } settimeout (' Myrefresh () ', 1000); Specify 1 seconds to refresh once </script>   JS Refresh frame script statement  //How to refresh the page containing the frame with    <script language=javascript> & nbsp  parent.location.reload (); </script>       //child window Refresh parent window <script language=javascript>     Self.opener.location.reload (); </script> (or <a href= "javascript:opener.location.reload ()" > Refresh </a>  )  //How to refresh the page of another frame with & nbsp;  <script language=javascript>    parent. Another FrameID.location.reload (); </script>   If you want to close the window or refresh when you want to open windows, call the following statement in <body>.   <body onload= "opener.location.reload ()" > Windows refresh <body onunload= "Opener.location.reload ()" > Refresh when closed   <script language= "JavaScript" > Window.opener.document.location.reload () </script>      
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.