Javascript Window.open 函数允许在将 resizable 属性设置为“0”后调整寡妇的大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6843249/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 23:25:26  来源:igfitidea点击:

Window.open function allowing to resize the widow after setting the resizable property as "0"

javascripthtmlpopup

提问by Able Alias

When I try to call a URL as a pop-up window through JavaScript, after loading the pop-up window I am able to re-size the window by mouse dragging even after I set the resizableproperty as "0". Code:

当我尝试通过 JavaScript 将 URL 作为弹出窗口调用时,加载弹出窗口后,即使将resizable属性设置为“0” ,我也可以通过鼠标拖动来重新调整窗口大小。代码:

        <script type="text/javascript">
        function poponload()
        {
            mywindow = window.open("factory.php?content=con1", "mywindow", "location=1,status=1,scrollbars=0,width=300,height=300,resizable=0");
            mywindow.moveTo(150, 150);
        }
    </script>

Please clarify if I made any mistake in the code.

请澄清我是否在代码中犯了任何错误。

采纳答案by epascarello

Modern day browsers can block window.open settings. There are no ways to override it unless you manually go to the user's computer and uncheck the checkbox for them.

现代浏览器可以阻止 window.open 设置。除非您手动转到用户的计算机并取消选中它们的复选框,否则无法覆盖它。

Pop up windows should be avoided in this day and age. Modal layers placed on the page that are updated with Ajax or iframes can do the same thing and have no size, menubar, and other restrictions placed on them.

在这个时代应该避免弹出窗口。页面上使用 Ajax 或 iframe 更新的模态层可以做同样的事情,并且没有大小、菜单栏和其他限制。

回答by BALKANGraph

The following code opens a window with menu bar. The window is re-sizable and is having 350 pixels width and 250 pixels height.

以下代码打开一个带有菜单栏的窗口。该窗口可重新调整大小,宽度为 350 像素,高度为 250 像素。

window.open ("http://www.google.com","mywindow","menubar=1,resizable=1,width=350,height=250");

回答by Ahsan Rathod

Use: window.resizeTo(width,height)

使用:window.resizeTo(width,height)