js implements a method summary that refreshes iframe

  • 2020-06-01 08:17:45
  • OfStack

Summary of javascript's method of refreshing iframe. Now suppose there is an iframe like the following, then the N methods of refreshing iframe are as follows:

<iframe src="1.htm" name="ifrmname" id="ifrmid"></iframe>

Method 1: locate with the name property of iframe

<input type="button" name="Button" value="Button" onclick="document.frames('ifrmname').location.reload()">


<input type="button" name="Button" value="Button" onclick="document.all.ifrmname.document.location.reload()">

The second method USES the id attribute of iframe

<input type="button" name="Button" value="Button" onclick="ifrmid.window.location.reload()">

Method 3: when iframe's src is another website address (i.e. when operating across domains)

<input type="button" name="Button" value="Button" onclick="window.open(document.all.ifrmname.src,'ifrmname','')">

There are two iframe in the parent page, and one iframe is a list of links to another 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 () to refresh all the parent pages in the js submission of content iframe. Since the other iframe has no default url and can only be selected through a list, only the content of list iframe is displayed.
Use window.parent.frames [" list iframe name "].location=" list url" to refresh the list iframe, while the content iframe's own refresh will not be affected after submitting.


. Note the difference between: document all refreshAlarm or document frames (" refreshAlarm ") got the https: / / www ofstack. com/page that iframe label, so useful for src property operation.
refreshAlarm document. frames (" "). document iframe inside content, namely "https: / / www. ofstack. com/" in the content.

Summary of the implementation method of javascript(js) automatic page refresh:

Refresh once every 10 seconds. Add the following code snippet to the head TAB of the page:

<meta http-equiv="refresh"content="10;url= Jump pages or pages that need to be refreshed URL address ">

Refresh the page regularly (refresh 1 page at an interval of 2 seconds) :

<script language="javascript">
setTimeout("location.href='url'",2000);//url Is the page to refresh URL address

Direct page refresh event:

<script language="javascript">
// If you want to refresh iframe , then just put window Replace with responsive iframe the name The attribute value or ID Attribute values

Direct page refresh event:

<script language=''javascript''>
window.navigate(" This page url");

Direct page refresh event:

<input type="button" name="Button" value="Button" onclick="document.frames('ifrmname').location.reload()">

Refresh frame page:

<script language="javascript">

That's all for this article, I hope you enjoy it.

Related articles: