Javascript 使用 jquery 最大化文档上的窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8391255/
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-24 05:48:30  来源:igfitidea点击:

maximize window on document ready with jquery

javascriptjquery

提问by BuZz

That might sound like a stupid one but I can't find anything relevant : how to maximize the window on document readywith jquery ? Or any other generic solution that will work fine on all browsers...

这听起来可能很愚蠢,但我找不到任何相关内容:如何document ready使用 jquery最大化窗口?或者任何其他可以在所有浏览器上正常工作的通用解决方案......

Thanks guys ;)

谢谢你们 ;)

回答by Ryan

window.moveTo(0, 0);
window.resizeTo(screen.availWidth, screen.availHeight);

回答by klodoma

This is not possiblefor main windows, only for dynamic created windows( created with window.open)

不适用于主窗口,仅适用于动态创建的窗口(使用 window.open 创建)

according to:

根据:

Quote:

引用:

  • You can't resize a window or tab that wasn't created by window.open.
  • You can't resize a window or tab when it's in a window with more than one tab.
  • 您无法调整不是由 window.open 创建的窗口或选项卡的大小。
  • 当窗口或选项卡位于具有多个选项卡的窗口中时,您无法调整窗口或选项卡的大小。

The same of for chrome. Haven't checked IE/Safari though.

镀铬也是一样。不过还没有检查 IE/Safari。

回答by Saeed Neamati

I found this method. But I can't make it work. Theoretically, it should be possible to change the width and height of the screen, using positive values.

我找到了这个方法。但我不能让它工作。理论上,应该可以使用正值更改屏幕的宽度和高度。

window.resizeBy(xDelta, yDelta);

For more information, visit http://www.w3schools.com/jsref/met_win_resizeby.asp.

有关更多信息,请访问http://www.w3schools.com/jsref/met_win_resizeby.asp

回答by Naftali aka Neal

NO

You cannot do this

你不可以做这个

Control over the user's browser (minimize, maximize) is for the useronly.

对用户浏览器的控制(最小化、最大化)仅供用户使用。