简体   繁体   中英

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.

Create a JavaScript file and enter the following values

 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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