Home > Blockchain >  Change browser resolution to a certain size when pressed on a button
Change browser resolution to a certain size when pressed on a button

Time:01-16

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.

CodePudding user response:

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>

CodePudding user response:

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.

  • Related