1. reload method, which forces the browser to refresh the current page.
Syntax: location. reload ([bForceGet])
Parameter: bForceGet. An optional parameter. The default value is false. The current page is retrieved from the client cache. True, the GET method is used to obtain the latest page from the server, which is equivalent to clicking F5 ("refresh") on the client ")
| The code is as follows: |
Copy code |
<Script language = "JavaScript"> Window. location. reload (); </Script> |
In this way, the page is refreshed. Of course there are other methods, so how should we refresh the Framework page?
| The code is as follows: |
Copy code |
// Method 1
Document. getElementById ('frameid'). contentWindow. location. reload (true );
// Method 2 Document. getElementById ('youriframe'). src = src; |
Instance:
| The code is as follows: |
Copy code |
<Iframe id = "myframe" width = "100%" frameBorder = "0" src = "test.html" scrolling = "no"> </iframe> <Input type = "button" onclick = "javascript: refreshFrame ();" value = "Refresh Frame"/> <Script type = "text/javascript"> <! -- Function refreshFrame (){ Document. getElementById ('myframework'). contentWindow. location. reload (true ); } // --> </Script> |
II. Jquery implements force refresh
$ ('# Iframe'). attr ('src', $ ('# iframe'). attr ('src '));
3,If you want to refresh a new page, use the following code to refresh it.
| The code is as follows: |
Copy code |
// Refresh the page containing the framework <Script language = JavaScript> Parent. location. reload (); </Script> // Refresh the parent window in the child window <Script language = JavaScript> Self. opener. location. reload (); </Script> (Or <a href = "javascript: opener. location. reload ()"> refresh </a>) // Refresh the page of another framework <Script language = JavaScript> Parent. Another FrameID. location. reload (); </Script> |
Summary: A lot of documents. frames ('ifrmname'). location. reload () are no longer available on the Internet.