iframe子页面获取父页面元素的方法

时间:2022-12-21 11:28:31

http://www.jb51.net/article/42810.htm

http://www.cnblogs.com/LYshuqian/p/3312383.html

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

格式:window.frames["iframe的name值"].document.getElementById("iframe中控件的ID").click();

实例:window.frames["ifm"].document.getElementById("btnOk")


2.获取父元素:
$.('#objld', parent.document); 


在父页面获取iframe子页面的元素 :

$("#objid", document.iframes('iframe').document)      (这种方法不能使用)

或 
$(document.getElementById('iframeId').contentWindow.document.body).html() $(document.getElementById('iframeId').contentWindow.document.body).html()