This time I will bring you a detailed explanation of the case of JS getting the iframe of the parent window and the child window. What are the precautions for JS getting the iframe of the parent window and the child window? The following is a practical case, let's take a look. .
In web development, iframes are often used. It is inevitable that you need to use elements in the iframe in the parent window, or use elements of the parent window in the iframejs
Get the elements in the iframe in the parent window1,
格式:window.frames["iframe的name值"].document.getElementByIdx_x("iframe中控件的ID").click(); 实例:window.frames["ifm"].document.getElementByIdx_x("btnOk").click();
2,
Format:var obj=document.getElementByIdx_x("iframe的name").contentWindow; var ifmObj=obj.document.getElementByIdx_x("iframe中控件的ID");
Instance:
var obj=document.getElementByIdx_x("ifm").contentWindow; var ifmObj=obj.document.getElementByIdx_x("btnOk"); ifmObj.click();
Get the elements of the parent window in iframe
格式:window.parent.document.getElementByIdx_x("父窗口的元素ID").click(); 实例:window.parent.document.getElementByIdx_x("btnOk").click();
Others related articles!
Recommended reading:jquery ajax makes it adaptive to height when applying iframe
jquery js calls the iframe parent window with Detailed explanation of sub-window steps
Jquery to obtain the Dom element in the iframe page (with code)
The above is the detailed content of Detailed explanation of the case of JS getting the iframe of the parent window and child window. For more information, please follow other related articles on the PHP Chinese website!