Jquery obtains the data in the <IFRAME> reference subpage on the parent page.
<SCRIPT src = "jquery-1.3.1.js" type = "text/JavaScript"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
// Search for all child nodes (including text nodes) within the matching element. If the element is an IFRAME, search for the document content.
// Obtain the element in the <IFRAME> reference subpage.
$ (Document). Ready (function (){
// BTN is the button element in the parent page
$ ("# BTN"). Click (function (){
// Form1 is the form Element in the Child page
Alert ($ ("# iframe1"). Contents (). Find ("# form1" ).html ());
});
});
// Call the button on the parent page to call the button method on the Child page
$ (Document). Ready (function (){
// BTN parent page button
$ ("# BTN"). Click (function (){
// Btnsave is the subpage button referenced by <IFRAME>
$ ("# Iframe1"). Contents (). Find ("# btnsave"). Click ();
});
});
// Obtain the value of an element on the Child page
$ (Document). Ready (function (){
$ ("# BTN"). Click (function (){
// Select: eq (0) to obtain the value of the first select drop-down list
VaR TXT = $ ("# iframe1 "). CONTENTS (). find ("# form1 Div select: eq (0 )"). find ("option: Selected "). text ();
Alert (txt );
});
});
</SCRIPT>
IFRAME is often used in web development, and elements that need to be used in the IFRAME in the parent window or in the IFRAME framework
JS
Obtain the elements in IFRAME in the parent window.
1,
Format: window. Frames ["iframe name value" 2.16.doc ument. getelementbyidx_x ("Control ID in IFRAME"). Click ();
Example: window. Frames ["IFM" mirror.doc ument. getelementbyidx_x ("btnok"). Click ();
2,
Format:
VaR OBJ = Document. getelementbyidx_x ("iframe name"). contentWindow;
VaR ifmobj1_obj.doc ument. getelementbyidx_x ("Control ID in IFRAME ");
Ifmobj. Click ();
Instance:
VaR OBJ = Document. getelementbyidx_x ("IFM"). contentWindow;
VaR ifmobj1_obj.doc ument. getelementbyidx_x ("btnok ");
Ifmobj. Click ();
Get the elements of the parent window in IFRAME
Format: Required parameter parent.doc ument. getelementbyidx_x ("parent window element ID"). Click ();
Example: Response response parent.doc ument. getelementbyidx_x ("btnok"). Click ();
Jquery
Obtain the elements in IFRAME in the parent window.
1,
Format: $ ("# iframe id"). Contents (). Find ("# Control ID in IFRAME"). Click (); // jquery method 1
Example: $ ("# IFM"). Contents (). Find ("# btnok"). Click (); // jquery method 1
2,
Format: $ ("# Control ID in IFRAME", document. Frames ("frame name" ).doc ument). Click (); // jquery method 2
Example: $ ("# btnok", document. Frames ("IFM" example .doc ument). Click (); // jquery method 2
Get the elements of the parent window in IFRAME
Format: $ ('# element ID in the parent window', parent.doc ument). Click ();
Instance: $ ('# btnok', parent.doc ument). Click ();