Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the size of the screen, current web page and browser window

How can I get windowWidth, windowHeight, pageWidth, pageHeight, screenWidth, screenHeight, pageX, pageY, screenX, screenY which will work in all major browsers?

screenshot describing which values are wanted

like image 393
turtledove Avatar asked Aug 09 '10 06:08

turtledove


People also ask

Which object is used to retrieve information about window size and height?

The window. screen object contains information about the user's screen.

How do I check my screen size in CSS?

You can use device-width which will test of the screen's width in px. That however is not entirely recommended. Use max-width and min-width (for the viewport) instead. If you are trying to GET the screen width and use it (something like content: (device-width); of some sort, that's not possible.


1 Answers

You can get the size of the window or document with jQuery:

// Size of browser viewport. $(window).height(); $(window).width();  // Size of HTML document (same as pageHeight/pageWidth in screenshot). $(document).height(); $(document).width(); 

For screen size you can use the screen object:

window.screen.height; window.screen.width; 
like image 103
Ankit Jaiswal Avatar answered Oct 11 '22 13:10

Ankit Jaiswal