Javascript iframe innerHTML [英] Javascript Iframe innerHTML

查看:117
本文介绍了Javascript iframe innerHTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何从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

推荐答案

我认为这就是你想要的:

I think this is what you want:

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 iframe innerHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆