【发布时间】:2010-11-24 04:21:52
【问题描述】:
我正在尝试访问 iframe 的父窗口并设置 iframe 的高度。
以下代码适用于 Windows IE7/IE8/Chrome/FireFox 3.6 和 Mac FireFox/Safari。
但在 Mac Chrome 上,它似乎没有访问父窗口。
在父页面上我有一个 iframe:
<iframe src="iframe_saleinfo.html" id="saleInformationIframe" frameborder="0"></iframe>
在 iframe.html 中:
$(document).ready(function() {
var theFrame = $('#saleInformationIframe', window.top.document);
theFrame.height($(document.body).height() + 30);
});
我也试过了:
$(document).ready(function() {
var theFrame = $('#saleInformationIframe', top.document);
theFrame.height($(document.body).height() + 30);
});
我已经试过了:
$(document).ready(function() {
var theFrame = $('#saleInformationIframe', parent.document.body);
theFrame.height($(document.body).height() + 30);
});
我试过了:
$(document).ready(function() {
var theFrame = $('#saleInformationIframe', window.parent.document);
theFrame.height($(document.body).height() + 30);
});
提前致谢,
杰德。
【问题讨论】:
标签: macos iframe google-chrome window parent