js---iframe

一、获取iframe父页面元素

1、Jquery方法

方法一:
            $("#父窗口元素ID",window.parent.document);
            父窗口的父窗口的元素就可以用:$(selector, window.parent.parent.document);
方法二:
            $(window.parent.document).find(selector);
方法三:
            $("").parent().find("");

2、Js方法

window.parent.document.getElementById("父窗口的元素ID");

二、在父窗口中获取iframe中的元素 

1、Jquery方法

方法一:

            $("#iframe的ID").contents().find("#iframe中的控件ID")

方法二:

            $("#iframe中的控件ID",document.frames("frame的name").document)

2、js方法

方法一:

            window.frames["iframe的name值"].document.getElementById("iframe中控件的ID")

方法二:

           document.getElementById("iframe").contentWindow.document.getElementById("元素id")

原文地址:https://www.cnblogs.com/zhengziru/p/9148995.html