Can I resize a window using jQuery or javascript?

I will create 5 buttons. Example:

Button1 value : 640*480 Button2 value : 1024*600 Button3 value : 1600*900 Button4 value : 800*600 

If the user clicks the button, I want to resize the browser window. I would like to do this through jQuery, but JavaScript is good too.

EDIT:

And how can I change the position of the window for the computer screen. Third question :) How can I create a random number?

+6
source share
2 answers

window.resizeTo () and window.moveTo ()

 function changeSize( w, h){ window.resizeTo(w,h); } function movePosition( x, y){ window.moveTo(x,y); } 

Modern browsers have settings that can prevent the browser window from resizing / moving / resizing.

[EDIT] Get a good JavaScript link. Math.random

+16
source

In addition to epascarello answer.

 var randomnumber=Math.floor(Math.random()*11) 

This code is for a random number between 0 and 10. Change 11 to whatever you want for the increased / decreased range.

0
source

Source: https://habr.com/ru/post/898595/


All Articles