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
- Gets an object based on the ID of the IFRAME
- var i1 = window.frames[' Iframeid '];
- var iframe =window.frames[0]; you can also
- Get the value of an element in an IFRAME
- var Val=i1.document.getelementbyid ("T1"). Value
(2) Gets the value of the element in the parent page in the IFRAME:
JS Code
- 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
- var i1 = parent.window.frames[' Iframeid '];
- 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