This article introduces JS and jquery to obtain the parent window, the child window of the IFRAME. Need friends can come to the reference, I hope to help you.
In web development, often use IFRAME, inevitably encounter the need in the parent window to use the elements in the IFRAME, or in the IFRAME frame using the parent window elements JS in the parent window to get the elements in the IFRAME 1, Format: window.frames["The name value of the IFRAME"].document.getelementbyidx_x ("ID of the control in the IFrame"). Click (); Example: window.frames["IFM"].document.getelementbyidx_x ("Btnok"). Click (); 2, format: var obj=document.getelementbyidx_x ("Name of IFrame"). Contentwindow; var ifmobj=obj.document.getelementbyidx_x ("ID of the control in the IFrame"); Ifmobj.click (); Example: var obj=document.getelementbyidx_x ("IFM"). Contentwindow; var ifmobj=obj.document.getelementbyidx_x ("Btnok"); Ifmobj.click (); Gets the element format of the parent window in the IFRAME: window.parent.document.getElementByIdx_x (the element ID of the parent window). Click (); Example: window.parent.document.getElementByIdx_x ("Btnok"). Click (); jquery Getting the elements in the IFRAME in the parent window 1, format: $ ("#iframe的ID"). Contents (). Find ("#iframe中的控件ID"). Click ();//jquery Method 1 Example: $ ("#ifm"). Contents (). Find ("#btnOk"). Click ();//jquery Method 1 2, Format: $ ("#iframe中的控件ID", Document.frames ("Name of Frame"). Document). Click ();//jquery Method 2 instance: $ ("#btnOk", Document.frames ("IFM"). Document). Click ();//jquery Method 2 Get the element format of the parent window in the IFRAME: $ (' #父窗口中的元素ID ', parent.document). Click (); Example: $ (' #btnOk ', parent.document). Click ();