我可以使用 Javascript 将不可调整大小的现有浏览器窗口更改为可调整大小吗?
简单的问题,我有一个使用此代码打开的窗口
window.open(URL, windowName, 'resizable=no');
我知道我可以在加载后以编程方式控制大小和位置 但我如何才能让它再次可重新调整?有什么办法可以覆盖它吗?
(注意:我无权修改打开代码,但可以完全访问子窗口代码)
Simple question, I have a window that was opened with this code
window.open(URL, windowName, 'resizable=no');
I know I can control size and position programmatically after it's loaded
but how do I make it simply reziable again? is there any way to override it?
(NOTE: I have no access to modify the opening code, but have full access to the child window code)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
黑客可能是这样的:
但它会导致您的窗口打开一个新窗口并自行关闭,这不是一个好的用户体验
A hack can be this:
but it cause your window open a new window and close itself that is not a good UX
您可以像这样调整子窗口的大小:
至于再次调整子窗口的大小,我认为您不能。父窗口可以控制子窗口。
You can resize the child window like this:
As for making the child window resizable again, I don't think you can. The parent window has control of the child.
不,窗口是否可调整大小是在打开时确定的。事后更改此标志是不可能的。根据您的目标,打开一个新的(可调整大小的)子窗口并关闭旧的子窗口可能是一种选择,我认为没有任何选择。
No, whether a window is resizable is determined when it is opened. Changing this flag after the fact isn't possible. Depending on your goal opening a new (resizable) child window and closing the old one might be an option, I don't think there are any alternatives.
我在 w3c 网站中找不到它,因此这可能已被弃用,但是 window.setResizes(true ) 应该将其自己的窗口设置为可调整大小。
尝试一下,查看链接以获取有关限制的更多信息。
此处还列出了该方法。
当然,在控制了孩子之后,我想你也可以从中创建一个新的孩子,作为最后的手段。
I can't find it in w3c site so this might be deprecated, but window.setResizable(true) should set it's own window resizeable.
Give it a try, check the link for more information on the restrictions.
The method is also listed here.
Of course that, having control over the child, you could also create a new child from it I guess, as a last resort.
您可以使用resizeTo到您的宽度和高度来更改窗口大小
you can use resizeTo to your width and height to change the window size