There are many methods for js to refresh the page, among which window.location.reload(), window.history.go(0) and document.execCommand(''Refresh''), these three methods are the fastest. Others have visible browser scrollbars appearing.
[The difference between window.location.href, window.location.replace(), window.location.reload(), which I will summarize in the following article]
js to refresh the page in several ways:
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
The method of automatically refreshing the page: Detailed explanation of the method of javascript automatically refreshing the page
1. Automatic page refresh: add the following code to the <head> area
<meta http-equiv="refresh" content="20">
Where 20 refers to 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.jbxue.com">
20 of them refer to jumping to http://www.jbxue.com page every 20 seconds
3. The page automatically refreshes the js version
<script language="JavaScript"> function myrefresh() { window.location.reload(); } setTimeout('myrefresh()',1000); //Specify refresh once every second </script>
Script statement of JS refresh frame
//How to refresh the page containing the frame with <script language=JavaScript> parent.location.reload(); </script> //The child window refreshes the parent window <script language=JavaScript> self.opener.location.reload(); </script> www.jbxue.com ( 或 <a href="javascript:opener.location.reload()">刷新</a> ) //How to refresh the page of another frame with <script language=JavaScript> parent.another FrameID.location.reload(); </script>
If you want to refresh when the window is closed or when the window is opened, you can call the following statement in <body>.
<body onload="opener.location.reload()"> Refresh when the window is opened <body onUnload="opener.location.reload()"> refresh when closed <script language="javascript"> window.opener.document.location.reload() </script>
.