jquery Tutorials
In web development, an IFRAME is often used, and it is unavoidable to encounter elements in the IFRAME that need to be used in the parent window, or to use the parent window in the IFRAME framework
Js
Gets the elements in the IFRAME in the parent window
1.
Format: window.frames["The name value of the IFRAME"].document.getelementbyid ("ID of the control in the IFrame"). Click ();
Example: window.frames["IFM"].document.getelementbyid ("Btnok"). Click ();
2.
Format:
var Obj=document.getelementbyid ("Name of IFrame"). Contentwindow;
var Ifmobj=obj.document.getelementbyid ("ID of the control in the IFrame");
Ifmobj.click ();
Instance:
var Obj=document.getelementbyid ("IFM"). Contentwindow;
var Ifmobj=obj.document.getelementbyid ("Btnok");
Ifmobj.click ();
Gets the element of the parent window in the IFRAME
Format: Window.parent.document.getElementById (the element ID of the parent window). Click ();
Example: Window.parent.document.getElementById ("Btnok"). Click ();
Jquery
Gets the elements in the IFRAME in the parent window
1.
Format: $ ("#iframe的ID"). Contents (). Find ("#iframe中的控件ID"). Click ();//jquery Method 1
Instance: $ ("#ifm"). Contents (). Find ("#btnOk"). Click ();//jquery Method 1
2.
Format: $ ("#iframe中的控件ID", Document.frames ("frame name"). Document). Click ();//jquery Method 2
Instance: $ ("#btnOk", Document.frames ("IFM"). Document). Click ();//jquery Method 2
Gets the element of the parent window in the IFRAME
Format: $ (' #父窗口中的元素ID ', parent.document). Click ();
Example: $ (' #btnOk ', parent.document). Click ();