IFrame and Parent page pass value

Source: Internet
Author: User

A number of IFRAME has been used in recent projects and needs to be implemented:
Gets the value of an element in the IFRAME from the parent page or the value of an element on its parent page from the IFRAME page.
On the Internet to check the relevant things, summed up as follows:
(1) The parent page Gets the value of the element in the IFRAME:
JS Code

    1. Gets an object based on the ID of the IFRAME
    2. var i1 = window.frames[' Iframeid '];
    3. var iframe =window.frames[0]; you can also
    4. Get the value of an element in an IFRAME
    5. var Val=i1.document.getelementbyid ("T1"). Value


(2) Gets the value of the element in the parent page in the IFRAME:
JS Code

    1. var val = parent.document.getElementById ("Txt1");


(3) A contains 2 iframe b,c, and now gets the value of the element in C from B:
JS Code

    1. var i1 = parent.window.frames[' Iframeid '];
    2. var val = i1.document.getElementById ("Text1"). Value;


Note: The upper code applies to IE. I IE8 under the test, FIREFOX3 under the operation (because the project only requires IE, does not require Firefox). The following two sentences quoted by other friends on the net:
Window.opener refers to the parent page of a page that window.open opens.
The Window.frames object can refer to a page in an IFRAME or to a page in frameset.
I uploaded the test page for easy reference. I have limited skills, there is a wrong place to write, I hope friends to correct! ^_^

      • Iframe_page.rar (1.3 KB)
      • Download number of times: 84

IFrame and Parent page pass value

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.