弹出窗口大小

发布于 2024-11-28 16:21:49 字数 188 浏览 4 评论 0原文

我想创建一个具有定义大小的弹出窗口,就像 BBC 所做的。如您所见,当您单击“实时收听”时,他们会打开一个弹出播放器,但我不明白他们是如何做到的。

有机会解释吗?

抱歉,JavaScript 新手

I want to create a popup that will have a defined size like the BBC did. As you can see, when you click "Listen Live", they open a popup player, but I didn't understand how they did that.

Any chance for explanation?

Sorry, newbie in JavaScript

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

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

发布评论

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

评论(1

抱着落日 2024-12-05 16:21:49

尝试使用这个函数:

    openChildWindowWithDimensions = function(url, width, height, showMenu, canResize, showScrollbars) {
        var childWindow = window.open(url, "", "\"width=" + width + ",height=" + height + ",menubar=" + (showMenu ? "1" : "0") + ",scrollbars=" + (showScrollbars ? "1" : "0") + ",resizable=" + (canResize ? "1" : "0") + "\"");
        if (childWindow){
            childWindow.resizeTo(width, height);
        }
    }

由于 IE9 中的错误,我添加了调整窗口大小的逻辑。根据您使用的浏览器,您可能不需要这一点。

Try using this function:

    openChildWindowWithDimensions = function(url, width, height, showMenu, canResize, showScrollbars) {
        var childWindow = window.open(url, "", "\"width=" + width + ",height=" + height + ",menubar=" + (showMenu ? "1" : "0") + ",scrollbars=" + (showScrollbars ? "1" : "0") + ",resizable=" + (canResize ? "1" : "0") + "\"");
        if (childWindow){
            childWindow.resizeTo(width, height);
        }
    }

I added the logic to resize the window because of a bug in IE9. Depending on what browser you're using, you may not need that bit.

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