Home > Article > Web Front-end > Summary of js methods to refresh iframe_javascript skills
A summary of the methods of refreshing iframe in JavaScript. Now assuming that there is an iframe like the following, the N methods of refreshing the iframe are:
The first method: use the name attribute of iframe to locate
or
The second method: use the id attribute of the iframe to locate
Third method: When the src of the iframe is the address of another website (i.e. cross-domain operation)
There are two iframes in the parent page. One iframe is a list of links, and the links in it point to the other iframe for displaying content. Now when the content content is added and a record is added to the linked list, the list iframe needs to be refreshed.
Use parent.location.reload() in the submission js of the content iframe to refresh all the parent pages. Because the other iframe does not have a default URL and can only be selected through the list, only the content of the list iframe is displayed.
Use window.parent.frames["list iframe name"].location="list url" to refresh the list iframe, and the refresh of the content iframe will not be affected after submission.
Note the difference: document.all.refreshAlarm or document.frames("refreshAlarm") gets the iframe tag in the http://www.jb51.net/ page, so operate on the src attribute it works.
document.frames("refreshAlarm").document gets the content inside the iframe, which is the content in "http://www.jb51.net/".
Summary of the implementation method of javascript(js) automatically refreshing the page:
Refresh every 10 seconds and add the following code snippet to the head tag of the page:
Refresh the page regularly (refresh the page every 2 seconds):
Direct refresh page event:
Direct refresh page event:
Direct refresh page event:
Refresh the frame page:
The above is the entire content of this article, I hope you all like it.