Skip to content
Fix Code Error

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

March 13, 2021 by Code Error
Posted By: Anonymous

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

Solution

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;
Answered By: Anonymous

Related Articles

  • How to move the player across a one background image?
  • How to set cell spacing and UICollectionView -…
  • Javascript - Track mouse position
  • How to solve Internal Server Error in Next.Js?
  • Animating Elements in One by One
  • WPF RichTexBox printing is creating unexpected line breaks
  • Using jQuery how to get click coordinates on the target…
  • Swift: Determine iOS Screen size
  • jQuery Mobile: document ready vs. page events
  • Unable to initialize variables according to Device Size

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Convert a Unix timestamp to time in JavaScript

Next Post:

How to terminate a Python script

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Get code errors & solutions at akashmittal.com
© 2022 Fix Code Error