Js updates iframe method summary, js refreshes iframe Summary

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.