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

2020-05-19 07:33:12易采站长站整理

在iframe子页面获取父页面元素
代码如下:

$.(‘#objld’, parent.document);

在父页面获取iframe子页面的元素
代码如下:

$(“#objid”, document.iframes(‘iframe’).document)



$(document.getElementById(‘iframeId’).contentWindow.document.body).html() $(document.getElementById(‘iframeId’).contentWindow.document.body).html()

显示iframe中body元素的内容

$(“#testId”, document.frames(“iframename”).document).html()