Javascript iframeinnerHTML [英] Javascript Iframe innerHTML
本文介绍了Javascript iframeinnerHTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道如何从 IFRAME 中获取 HTML 我尝试了几种不同的方法:
Does anyone know how to get the HTML out of an IFRAME I have tried several different ways:
document.getElementById('iframe01').contentDocument.body.innerHTML
document.frames['iframe01'].document.body.innerHTML
document.getElementById('iframe01').contentWindow.document.body.innerHTML
等
推荐答案
我想这就是你想要的:
window.frames['iframe01'].document.body.innerHTML
我确信这在 Chrome 和 Firefox 中不起作用,尽管它在 IE 中运行良好,这是我测试它的地方.回想起来,这是一个很大的错误
I have it on good authority that this won't work in Chrome and Firefox although it works perfectly in IE, which is where I tested it. In retrospect, that was a big mistake
这会起作用:
window.frames[0].document.body.innerHTML
我知道这不是我们所问的,但我不想删除答案,因为我认为它有位置.
I understand that this isn't exactly what was asked but don't want to delete the answer because I think it has a place.
我喜欢下面@ravz 的 jquery 答案.
I like @ravz's jquery answer below.
这篇关于Javascript iframeinnerHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文