1. How to use the link: Copy code The code is as follows:<a href="javascript:history.go(-1);">Return to the previous page</a> <a href="#top">Refresh current page</a> The #top effect didn't work for me, but it worked when I directly wrote <a href="">Refresh current page</a>. 2. How to refresh the current page with JS The reload method forces the browser to refresh the current page. Syntax: location.reload([bForceGet]) Parameter: bForceGet, optional parameter, default is false, get the current page from the client cache. true, then the latest page is retrieved from the server using GET, which is equivalent to the client clicking F5 ("refresh") The replace method replaces the item currently cached in the history (client) by the specified URL. Therefore, after using the replace method, you cannot access the replaced URL by "forward" and "backward". Syntax: location.replace(URL) In actual application, when refreshing the page, we usually use: location.reload() or history.go(0) to do it. Because this approach is like the client clicking F5 to refresh the page, when the page method="post", a "page expired" prompt will appear. That's because of the Session security protection mechanism. It can be imagined that: when the location.reload() method is called, the aspx page already exists in the server's memory, so it must be IsPostback. If there is such an application: We need to reload the page, that is, we expect the page to be recreated on the server, and we expect it to be Not IsPostback. Here, location.replace() can accomplish this task. The replaced page is regenerated on the server each time. You can write: location.replace(location.href); Go back and refresh the page: Copy code The code is as follows:location.replace(document.referrer); document.referrer //URL of the previous page Do not use history.go(-1) or history.back(); to return and refresh the page. These two methods will not refresh the page. Attachment: Several ways to refresh the page with Javascript: 1 history.go(0) 2 location.reload() 3 location=location 4 location.assign(location) 5 document.execCommand('Refresh') 6 window.navigate(location) 7 location.replace(location) 8 document.URL=location.href How to automatically refresh the page: 1. Automatic page refresh: Add the following code to the <head> area <meta http-equiv="refresh" content="20"> 20 means refreshing the page every 20 seconds. 2. Automatic page jump: Add the following code to the <head> area <meta http-equiv="refresh" content="20;url=http://www.wyxg.com"> 20 means jumping to http://www.wyxg.com after 20 seconds. 3. Page automatic refresh js version Copy code The code is as follows:<script language="JavaScript"> function myrefresh() { window.location.reload(); } setTimeout('myrefresh()',1000); //Specify refresh once every 1 second </script> JS refresh frame script statement Copy code The code is as follows://How to refresh the page containing the frame <script language=JavaScript> parent.location.reload(); </script> //The child window refreshes the 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 <script language=JavaScript> parent.anotherFrameID.location.reload(); </script> If you want to refresh when closing the window or when opening the window, just call the following statement in <body>. Copy code The code is as follows:<body onload="opener.location.reload()"> Refresh when opening the window <body onUnload="opener.location.reload()"> Refresh on close <script language="javascript"> window.opener.document.location.reload() </script> |
<<: Problems and solutions for deploying Nginx+KeepAlived cluster dual-active architecture in VMware
>>: 30 excellent examples of color matching in web design
This article shares the specific code of JavaScri...
<br />When you click the link, the web page ...
1. Download: http://www.oracle.com/technetwork/ja...
Table of contents 1. Installation and introductio...
[Problem description] On the application side, th...
1. Why do we need to divide tables and partitions...
The definition and inheritance of classes in JS a...
The nginx configuration file is mainly divided in...
remember: IDE disk: the first disk is hda, the se...
Table of contents Environmental Description Insta...
bmi Voyager Pitchfork Ulster Grocer Chow True/Sla...
1. Installation Tip: There is currently no offici...
Canal is an open source project under Alibaba, de...
1. Uninstalling MySQL 5.7 1.1查看yum是否安裝過mysql cd y...
This article shares the installation and configur...