screen.width
JavaScript 1.2+, JScript 3+ Nav4+, IE4+ Syntax
screen.width
Description
The width property of the screen object accesses the width of the user's screen in pixels.
Example
Listing 7.462 displays the width of the user's screen to the page.
Listing 7.462 Accessing the width Property of the screen Object
<script language="JavaScript1.2"> <!-- Hide document.write("The width of this user's screen is <b>"); document.write(screen.width + '</b> pixels'); // End hide ---> </script> |
Get Pure JavaScript 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.