【发布时间】:2014-09-05 03:50:20
【问题描述】:
我很无奈。我需要使用 Javascript 或 Jquery 从 iframe 获取源代码。
iframe 的源文件在同一个域中。这是我的 iframe:
<iframe src="/source_file.html" id="iframe_id"></iframe>
我正在使用以下如此著名的语法从 iframe 中获取源代码:
document.getElementById("iframe_id").contentWindow.document.body.innerHTML
但是使用这段代码,我只能在 BODY 元素中获取代码。我想获取从 到 的完整代码。
请帮帮我。
【问题讨论】:
-
尝试
$('html', document.getElementById("iframe_id").contentWindow.document)[0].outerHTML仍然不会给出文档类型
标签: javascript jquery html iframe