在javascript中获取框架的高度

发布于 2024-09-18 05:29:30 字数 140 浏览 3 评论 0原文

我目前正在一个带有一些遗留表示层的系统中工作——它使用框架(实际上,在框架集框架中)。

为了让一些事件处理启动并运行,我希望在框架调整大小时获取事件,或者至少能够以某种方式测量框架的高度。似乎没有跨浏览器的方法可以做到这一点。有人尝试过这样的事情吗?

I'm currently working in a system with a bit of a legacy presentation layer -- it uses frames (actual, in a frameset frames).

To get some event handling up and running I would like to get events when the frame resizes or at least be able to measure the height of the frame somehow. There seems to be no cross browser way to do this. Has anyone tried anything like this?

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

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

发布评论

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

评论(1

凤舞天涯 2024-09-25 05:29:34

试试这个 - 另外你可能也必须在所有浏览器上尝试这个 -

<!-- 
     Example File From "JavaScript and DHTML Cookbook"
     Published by O'Reilly & Associates
     Copyright 2003 Danny Goodman
-->


function getFrameSize(frameID) {
    var result = {height:0, width:0};
    if (document.getElementById) {
        var frame = parent.document.getElementById(frameID);
        if (frame.scrollWidth) {
            result.height = frame.scrollHeight;
            result.width = frame.scrollWidth;
        }
    }
    return result;
}

Try this - Also you might have to try this on all browsers too -

<!-- 
     Example File From "JavaScript and DHTML Cookbook"
     Published by O'Reilly & Associates
     Copyright 2003 Danny Goodman
-->


function getFrameSize(frameID) {
    var result = {height:0, width:0};
    if (document.getElementById) {
        var frame = parent.document.getElementById(frameID);
        if (frame.scrollWidth) {
            result.height = frame.scrollHeight;
            result.width = frame.scrollWidth;
        }
    }
    return result;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文