iframe元素的获取方式:
1. 获取iframe的window对象
iframe.contentWindow
2. 获取iframe的document对象
iframe.contentDocument
- 父页面调用子iframe页面
<!--js方法-->
1. 使用contentWindow属性
document.getElementById('iframeId').contentWindow.document.getElementById('子页面中的元素ID');
2. 通过iframe的name(名字)直接获取
iframeName.window.document.getElementById('子页面中的元素ID');
3. 通过window对象的frames[]数组对象直接获取子frame对象
window.frames[0].document.getElementById('子页面中的元素ID');
或者
window.frames["iframeName"].document.getElementById('子页面中的元素ID');
- 子iframe页面调用父页面
1. 通过parent对象获取父页面的window对象内元素及方法
parent.window.document.getElementById('');
2. 通过top对象获取父页面的window对象内元素及方法
top.window.document.getElementById();
- 主页面内兄弟iframe页面之