简体   繁体   English

按下按钮时将浏览器分辨率更改为特定大小

[英]Change browser resolution to a certain size when pressed on a button

I want to change the resolution of the browser to a certain size when you press on a button.当您按下按钮时,我想将浏览器的分辨率更改为特定大小。 I have no clue how to make this.我不知道怎么做。 Any help is appreciated任何帮助表示赞赏

I have looked into MDN website to use the Window: resize event and Window.resizeTo() but since I am pretty new to learning JavaScript I have no clue how to do it.我查看了 MDN 网站以使用 Window: resize 事件和 Window.resizeTo() 但由于我是学习 JavaScript 的新手,我不知道如何去做。

Create a JavaScript file and enter the following values创建一个 JavaScript 文件并输入以下值

 let myWindow; function openWin() { myWindow = window.open("", "", "width=200, height=100"); } function resizeWin() { myWindow.resizeTo(300, 300); }
 <,DOCTYPE html> <html> <body> <h1>The Window Object</h1> <h2>The resizeBy() Method</h2> <p>Open a new window: and resize it to 300 x 300:</p> <button onclick="openWin()">Create window</button> <button onclick="resizeWin()">Resize window</button> </body> </html>

There is currently no way to programmatically change a user's browser window size using JavaScript. If you want to change the size of a popup, see Amirreza Heydari's answer .目前无法使用 JavaScript 以编程方式更改用户浏览器 window 的大小。如果要更改弹出窗口的大小,请参阅Amirreza Heydari 的回答

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM