诚然,这是一个令人厌烦的话题,但我完全陷入困境:
我正在尝试使用 jquery autoheight 插件(https://github.com/house9/jquery-iframe-auto-height)和 jQuery v1.7 将 iframe 的高度设置为其内容高度。
由于跨域问题,我构建了一个(curl-)包装器,因此所有内容都在同一个域中。iframe 的 html 标记如下所示:
<iframe scrolling="no" frameborder="0" src="/de/pressrelease/proxy/?uri=<my-uri>"></iframe>
不幸的 jquery 吐出这个错误:[错误:访问属性'ownerDocument'的权限被拒绝]
我已经做了很多研究,例如检查了这个问题:Permission denied to access property in IFRAME
甚至尝试在 iframe 源中设置绝对 uri - 同样的错误。
来自父文档的响应头:
Date: Wed, 28 Nov 2012 09:42:11 GMT
Server: Apache
X-Powered-By: PHP/5.3.18-nmm1
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 3554
Keep-Alive: timeout=1, max=100
Connection: Keep-Alive
Content-Type: text/html
200 OK
curl-proxy-wrapper (iframe) 的标头:
Date: Wed, 28 Nov 2012 09:42:07 GMT
Server: Apache
X-Powered-By: PHP/5.3.18-nmm1
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4102
Keep-Alive: timeout=1, max=100
Connection: Keep-Alive
Content-Type: text/html
200 OK