Let's give you a quick introduction to some refreshing page statements
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
Timed page automatically refresh JS version
Program code
The code is as follows |
Copy Code |
<meta http-equiv= "Refresh" content= ">" |
or write like this
The code is as follows |
Copy Code |
<script language= "Javascript" > function Myrefresh () { Window.location.reload (); } SetTimeout (' Myrefresh () ', 1000); Specify 1 seconds to refresh once </script> |
Window.location.Reload () and window.location.href=window.location.href;
The code is as follows |
Copy Code |
<a onclick= "JAVASCRIPT:WINDOW.LOCATION.HREF=WINDOW.LOCATION.HREF;" >
<a onclick= "Javascript:window.location.reload ();" > |
The test effect is the same. The form was not submitted.
The code is as follows |
Copy Code |
<input type= "Submit" onclick= javascript:window.location.reload (); "Value=" click id= "Btnvcode"/> <input type= "Submit" onclick= "Javascript:window.location.href=window.location.href" value= "click" id= "BtnVCode"/ > |
All submit data
Window.location.Reload () should be refreshed. (If you have data to submit, you will be prompted whether to submit (Yes and no options))
Window.location.href=window.location.href; is directed URL submission data
It is best not to use Location.reload (), and use location=location better, there are in the Mode window (ShowModalDialog and showModelessDialog) The former can not be used.
JS Refresh window: Window.location.replace (window.location.href)
The code is as follows |
Copy Code |
Window.location.reload ();
Window.history.go (0); Window.location.assign (WINDOW.LOCATION.HREF) |
The difference between window.location.href and window.location.replace:
1.html-> 2.html-> 3.html
System from 1.html to 2.html, 2 has two buttons, BTN1 is window.location.href=3.html, BTN2 is Window.location.replace (3.html), After clicking Btn1, use Window.history.go ( -1) in 3, Window.history.back () and return 1.html.
and click Btn2 into 3 o'clock, with Window.history.go ( -1); Wondow.history.back (); returns 2.html.
Personal experiences and differences between WINDOW.LOCATION.HREF and Window.location.replace
When using Window.location.href it is useful to use Window.history.go (-1) or window.history.back ()
When using window.location.replace (' URL ') it is not useful to use Window.history.go (-1) or window.history.back ()
Window.location.replace ("3.jsp"); is a jump that does not send requests to the server
Window.history.go ( -1); Window.history.back (); method determines which page is to be skipped based on the server record request
Window.location.href ("3.jsp"); is the jump that sends the request to the server, Window.history.go ( -1); Wondow.history.back (); The method determines which page is to be skipped based on the server record request
JS Refresh Frame Script statement:
The code is as follows |
Copy Code |
How to refresh the page that contains the frame with <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 close the window when refreshing or when you want to open the window refresh, call the following statement in <body>:
The code is as follows |
Copy Code |
<body onload= "Opener.location.reload ()" > Refresh when opening windows <body onunload= "Opener.location.reload ()" > Refresh when closed <script language= "JavaScript" > Window.opener.document.location.reload () </script> |
Refresh another frame's page
Statement 1 window.parent.frames[1].location.reload ();
Statement 2 window.parent.frames.bottom.location.reload ();
Statement 3 window.parent.frames["bottom"].location.reload ();
Statement 4 Window.parent.frames.item (1). Location.reload ();
Statement 5 window.parent.frames.item (' Bottom '). Location.reload ();
Statement 6 window.parent.bottom.location.reload ();
Statement 7 window.parent[' bottom '].location.reload ();