Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript set browser window size

What is the best way to set the size of the browser window when the page loads? I think this can be done in JavaScript. Please explain. Here is my code that is not working!

<html>
<body onload="window.resizeTo(640,480)">
<video src="rushmore.mp4" controls="controls">
your browser does not support the video tag
</video>
</body>
</html>
like image 825
Web_Designer Avatar asked Mar 08 '11 21:03

Web_Designer


People also ask

How do I resize my browser window to a specific size?

Press Alt+Space to bring up the window menu, press S to choose the Size option, use the arrow keys to resize the window, and lastly Enter to confirm. Click the Maximize button in the top right corner of the window. Click the title bar and drag the window to the left, top, or right edge of the desktop.

How do I resize a browser window in HTML?

The resizeTo() method is used to resizes a window to the specified width and height. Parameter Values: width: Sets the width of the window, in pixels. height: Sets the height of the window, in pixels.

How do I know the size of my browser window?

Use window. innerWidth and window. innerHeight to get the current screen size of a page.


1 Answers

This should do the trick, setting the height and width to your desired dimensions.

window.resizeTo(500,500)

You could set it onload.

<body onload="window.resizeTo(500,500)">
like image 134
Dustin Laine Avatar answered Oct 14 '22 19:10

Dustin Laine