【发布时间】:2013-10-21 22:25:37
【问题描述】:
我正在通过我的网站中的 iframe 加载跨域页面 url。如下所示
<iframe class="iframeId" src="cross domain... /view/id/100" scrolling="no"></iframe>
我想在加载页面后为 iframe 设置高度 如果我使用下面的代码,跨域 url 会出现一些错误
$('.iframeId').load(function () {
this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
});
错误是“错误:访问属性'文档'的权限被拒绝”。 我的目标是在没有滚动条的 iframe 中加载页面。 那么我该如何解决这个问题呢?
【问题讨论】:
-
试试这个 $(this).outerHeight(true);或 $(this).css("height");