【发布时间】:2015-09-07 10:56:07
【问题描述】:
我想获取 iframe 的内容,但是发生了错误。
错误:访问属性“文档”的权限被拒绝
...irstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument...
我的代码:
<iframe frameborder="0" scrolling="no" width="130" height="198"
src="https://tpc.googlesyndication.com/simgad/9598136166282506848" name="imgbox" class="iView">
<p>iframes are not supported by your browser.</p>
</iframe>
$(document).ready(function(){
var cnt = $(".iView").contents();
console.log(cnt);
})
【问题讨论】:
-
似乎您正在 iFrame 中打开第三方网站并尝试访问其文档。你不能那样做。
-
有没有办法获取 iframe 内容???
-
如果 iFrame 有
src指向您自己的域中存在的网络资源,即主父页面的域,那么您可以访问其内容。
标签: javascript jquery html iframe