Mac Google Chrome iframe 访问父窗口

发布于 2024-10-03 22:47:34 字数 1150 浏览 0 评论 0原文

我正在尝试访问 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);
});

提前致谢,

Jayde。

I am trying to access the parent window of an iframe and set the iframe's height.

The following code works on Windows IE7/IE8/Chrome/FireFox 3.6 and on Mac FireFox/Safari.

But on Mac Chrome it doesn't appear to be accessing the parent window.

On the parent page I have an iframe:

<iframe src="iframe_saleinfo.html" id="saleInformationIframe" frameborder="0"></iframe>

In the iframe.html:

$(document).ready(function() {
    var theFrame = $('#saleInformationIframe', window.top.document);
    theFrame.height($(document.body).height() + 30);
});

I have also tried:

$(document).ready(function() { 
    var theFrame = $('#saleInformationIframe', top.document);
    theFrame.height($(document.body).height() + 30);
});

And I've tried:

$(document).ready(function() { 
    var theFrame = $('#saleInformationIframe', parent.document.body);
    theFrame.height($(document.body).height() + 30);
});

And I tried:

$(document).ready(function() { 
    var theFrame = $('#saleInformationIframe', window.parent.document);
    theFrame.height($(document.body).height() + 30);
});

Thanks in advance,

Jayde.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄凉少年不暖心 2024-10-10 22:47:34

这看起来像是 Chrome Mac 的本地问题。我的测试 Mac 上没有安装 Web 服务器,但当我将文件上传到服务器并从那里查看时,一切似乎都正常。

谢谢,

杰德。

It looks like a local issue with Chrome Mac. I don't have a web server installed on the test mac but when I uploaded the files to a server and viewed it from there, everything appears to work.

Thanks,

Jayde.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文