JavaScript Screen Object

The screen object in JavaScript represents the current display screen in your browser. Here is the general form to access the screen object property:


JavaScript Screen Object Properties

The following table describes the properties of the Screen object in JavaScript.

Property Description
availHeight specifies the height of the screen, excluding the Windows Taskbar
availWidth specifies the width of the screen, excluding the Windows Taskbar
colorDepth specifies the depth of the color palette, in bits, to display images
height specifies the total height of the screen
pixelDepth specifies the color resolution, in bits per pixel, of the screen
width specifies the total width of the screen

JavaScript Screen Object Example

Here is an example illustrates screen object in JavaScript:

   <title>JavaScript Screen Object</title>

<h3>JavaScript Screen Object Example</h3>
<script type="text/javascript">
   document.writeln("<b>Total Height = </b>" + screen.height + "<br/>");
   document.writeln("<b>Total Weight = </b>" + screen.width + "<br/>");
   document.writeln("<b>Available Width = </b>" + screen.availWidth + "<br/>");
   document.writeln("<b>Available Height = </b>" + screen.availHeight + "<br/>");
   document.writeln("<b>Screen Color Depth = </b>" + screen.colorDepth + "<br/>");
   document.writeln("<b>Screen Pixel Depth = </b>" + screen.pixelDepth + "<br/>");

Here is the sample output produced by the above screen object in JavaScript example:

javascript screen object

JavaScript Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube