JS How to refresh the current page

Source: Internet
Author: User
Tags server memory

the reload method, which forces the browser to refresh the current page. Syntax: Location.reload ([bforceget]) parameter: bforceget, optional parameter, default =falseTo fetch the current page from the client cache.true, the latest page from the server is taken as a GET, which is equivalent to the client clicking F5 ("Refresh"the Replace method, which replaces the currently cached item in history (client) by specifying 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) in the actual application, when re-refresh 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", there will be "page expiration"the prompt. That's because of the session's security protection mechanism. It can be thought that when the Location.reload () method is called, the ASPX page is already present in the server memory, so it must be IsPostback. If there is such an application: we need to reload the page, which means we expect the page to be re-created on the server and we expect it to be not IsPostback. Here, Location.replace () can complete this task. The Replace page is regenerated on the server each time. You can write: Location.replace (location.href); Back and Refresh page: Location.replace (document.referrer);d ocument.referrer//the URL of the previous pagedo not use History.go (-1), or history.back (); To go back and refresh the page, neither of these methods refreshes the page. Attached: Several ways JavaScript refreshes the page:1 history.go (0) 2location.reload ()3 location= Location4location.assign (location)5 Document.execcommand (' Refresh ') 6window.navigate (location)7location.replace (location)8 document. Url=location.href How to automatically refresh pages:1. Automatic page refresh: Add the following code area in<meta http-equiv= "Refresh" content= ">"20 refers to a refresh of the page every 20 seconds.2. Page Auto-jump: Add the following code area in<meta http-equiv= "Refresh" content= "20;url=http://www.wyxg.com" >where 20 refers to 20 seconds after the jump to http://www.wyxg.com Page3. Page auto-refresh JS version<script language= "JavaScript" >functionMyrefresh () {window.location.reload ();} SetTimeout (' Myrefresh () ', 1000);//Specify 1 seconds to refresh one time</script>JS Refresh Framework Script statement//How to refresh the page that contains the frame<script language=javascript>parent.location.reload ();</script>//child window refreshes parent window<script language=javascript>self.opener.location.reload ();</script> (or <a href= "javascript:opener.location.reload ()" > Refresh </a>)//How to refresh another frame's page with<script language=javascript>parent. Another FrameID.location.reload ();</script>If you want to refresh when you close the window or if you want to open the windows,<body>you can call the following statement in the <body onload= "Opener.location.reload ()" >Refresh when opening windows<body onunload= "Opener.location.reload ()" >Refresh when off<script language= "JavaScript" >window.opener.document.location.reload ()</script>

JS How to refresh the current page

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.