How can I get windowWidth
, windowHeight
, pageWidth
, pageHeight
, screenWidth
, screenHeight
, pageX
, pageY
, screenX
, screenY
which will work in all major browsers?
The window. screen object contains information about the user's screen.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With