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 ();