Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change window size with JQuery or JavaScript?

I will create 5 buttons. Example:

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

If the user clicks a button, I want it to change the browser window's size. I would like to do this via JQuery but JavaScript is fine too.

EDIT:

And how can i change windows' position for computer's screen. Third question :) how can i create random number?

like image 432
Programmer Avatar asked Oct 04 '11 14:10

Programmer


2 Answers

window.resizeTo() and window.moveTo()

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

Modern day browsers have settings that can prevent you have changing/moving/resizing the browser window.

[EDIT] Get yourself a good JavaScript reference. Math.random

like image 164
epascarello Avatar answered Oct 15 '22 21:10

epascarello


In addition to epascarello's answer.

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

That's the code for a random number between 0 and 10. Change 11 to whatever you want for an increased/decreased range.

like image 22
please delete me Avatar answered Oct 15 '22 21:10

please delete me