"Error: Permission denied to access property 'document'"
当我已经在我的定义中X-FRAME options
允许其他域时,我不断收到错误,就像这样..
<?php
header('X-Frame-Options: ALLOW-FROM http://mydomain.com');
?>
下面是 iframe 请求的标头,清楚地表明我已定义允许域访问 iframe 但不工作。我想要的只是使用 javascript 调整 iframe 的大小。
这是我调整 iframe 高度大小的 javascript 代码。
<iframe src="http://mydomain.com/xxx/yyy" id="idIframe" onload="iframeLoaded();" allowtransparency="true" frameborder="0" width="100%" scrolling="no"></iframe>
<script type="text/javascript">
function iframeLoaded() {
var iFrameID = document.getElementById('idIframe');
if(iFrameID) {
iFrameID.height = "";
if(iFrameID.contentWindow.document.body.scrollHeight < 500) {
iFrameID.height = "500px";
} else {
iFrameID.height = iFrameID.contentWindow.document.body.scrollHeight + "px";
}
}
}
</script>
我怎样才能做到这一点?请建议。