In web development, iframes are often used, and it is inevitable that you will encounter elements in iframes in parent windows, or elements in iframe frames that need to use elements in parent windows, or elements in parent windows in iframe frames
js
Get elements in iframe in parent window
1、
Format: ["iframe's name value"].document.getElementByIdx_x("Id of the control in iframe").click();
Example: ["ifm"].document.getElementByIdx_x("btnOk").click();
2、
Format:
var obj=document.getElementByIdx_x("iframe's name").contentWindow;
var ifmObj=.getElementByIdx_x("Id of the control in iframe");
();
Example:
var obj=document.getElementByIdx_x("ifm").contentWindow;
var ifmObj=.getElementByIdx_x("btnOk");
();
Get the element of the parent window in an iframe
Format: .getElementByIdx_x("Element ID of parent window").click();
Example: .getElementByIdx_x("btnOk").click();
jquery
Get elements in iframe in 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",("frame name").document).click();//jquery method 2
Example: $("#btnOk",("ifm").document).click();//jquery method 2
Get the element of the parent window in an iframe
Format: $('#Element ID', in parent window).click();
Example: $('#btnOk', ).click();