Getting the Screen Size
screen.availHeight; // returns screen height in pixels screen.availWidth; // returns screen width in pixels
An important feature of JavaScript these days is the ability to get the screen size. The screen sizes of browsers vary so much that you often need to use different sets of code for larger, medium, or smaller screens. To get the screen size, use the screen.availHeight
and screen.availWidth
attributes. These values are specified in the number of pixels.
Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.