Js updates iframe method summary, js refreshes iframe Summary
Summary of the method for refreshing iframe in javascript. If the following iframe exists, the following N methods are used to refresh the iframe:
Copy codeThe Code is as follows:
<Iframe src = "1.htm" name =" ifrmname "id =" ifrmid "> </iframe>
Method 1: use the name attribute of iframe to locate
Copy codeThe Code is as follows:
<Input type = "button" name = "Button" value = "Button" onclick = "document. frames ('ifrmname'). location. reload ()">
Or
Copy codeThe Code is as follows:
<Input type = "button" name = "Button" value = "Button" onclick = "document.all.ifrmname.doc ument. location. reload ()">
Method 2: Use the id attribute of iframe to locate
Copy codeThe Code is as follows:
<Input type = "button" name = "Button" value = "Button" onclick = "ifrmid. window. location. reload ()">
Method 3: When the src of iframe is another website address (that is, cross-origin Operation)
Copy codeThe Code is as follows:
<Input type = "button" name = "Button" value = "Button" onclick = "window. open (document. all. ifrmname. src, 'ifrmname', '')">
The parent page contains two iframe, one of which is a link list. The link points to another iframe, which is used to display the content. Now, when the content is added and a record is added to the link list, you need to refresh the list iframe.
Use parent in the submitted js of the content iframe. location. reload () refreshes 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. After the content iframe is submitted, its own refresh will not be affected.
Copy codeThe Code is as follows:
Document. frames ("refreshAlarm"). location. reload (true );
Document. frames ("refreshAlarm" 2.16.doc ument. location. reload (true );
Document. frames ("refreshAlarm" 2.16.doc ument. location = "http://www.bkjia.com /";
Document. frames ("refreshAlarm"). src = "http://www.bkjia.com /";
Note: document. all. refreshAlarm or document. frames ("refreshAlarm") returns the iframetag in http://www.bkjia.com/page, which is useful for src.pdf operations.
Document. frames ("refreshAlarm" ).doc ument get the content in iframe, that is, the content in "http://www.bkjia.com.
Summary of implementation methods for automatically refreshing pages in javascript (js:
Refresh every 10 seconds. Add the following code segment to the head tab of the page:
Copy codeThe Code is as follows:
<Meta http-equiv = "refresh" content = "10; url = redirected page or URL address of the page to be refreshed">
Regularly refresh the page (refresh the page every 2 seconds ):
Copy codeThe Code is as follows:
<Script language = "javascript">
SetTimeout ("location. href = 'url'", 2000); // The url is the url of the page to be refreshed.
</Script>
Directly refresh page events:
Copy codeThe Code is as follows:
<Script language = "javascript">
Window. location. reload (true );
// If you need to refresh iframe, you only need to replace window with the name attribute value or ID attribute value of the response iframe
</Script>
Directly refresh page events:
Copy codeThe Code is as follows:
<Script language = ''javascript ''>
Window. navigate ("url of this page ");
</Script>
Directly refresh page events:
Copy codeThe Code is as follows:
Function abc (){
Window. location. href = "/blog/window. location. href ";
SetTimeout ("abc ()", 10000 );
}
Refresh the framework page:
Copy codeThe Code is as follows:
<Script language = "javascript">
Top. leftFrm. location. reload ();
Parent. frmTop. location. reload ();
</Script>
The above is all the content of this article. I hope you will like it.