Js implementation refresh iframe method aggregation _ javascript skills

Source: Internet
Author: User
Here we have summarized some js methods for refreshing the iframe framework. this method is very simple and practical. if you need it, you can refer to it. Summary of the method for refreshing iframe in javascript. if the following iframe exists, the following N methods are used to refresh the iframe:

The code is as follows:



Method 1: Use the name attribute of iframe to locate

The code is as follows:



Or

The code is as follows:



Method 2: Use the id attribute of iframe to locate

The code is as follows:



Method 3: When the src of iframe is another website address (that is, cross-origin operation)

The code is as follows:



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.

The 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.jb51.net /";
Document. frames ("refreshAlarm"). src = "http://www.jb51.net /";

Note: document. all. refreshAlarm or document. frames ("refreshAlarm") returns the iframetag in http://www.jb51.net/page, which is useful for srcworkflow operations.
Document. frames ("refreshAlarm" ).doc ument get the content in iframe, that is, the content in "http://www.jb51.net.

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:

The code is as follows:



Regularly refresh the page (refresh the page every 2 seconds ):

The code is as follows:


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.