iframe通信(lg:父页面调用iframe页面的click方法)

获取iframe里的内容

主要的两个API就是contentWindow,和contentDocument

iframe.contentWindow, 获取iframe的window对象

iframe.contentDocument, 获取iframe的document对象

这两个API只是DOM节点提供的方式(即getELement系列对象)

var iframe = document.getElementById("iframe1");

var iwindow = iframe.contentWindow;varidoc = iwindow.document;

console.log("window",iwindow);//获取iframe的window对象

console.log("document",idoc);//获取iframe的document

console.log("html",idoc.documentElement);//获取iframe的html

console.log("head",idoc.head);//获取head

console.log("body",idoc.body);//获取body

console.log(window.frames['ifr1'].window);        // ==window

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容