[JavaScript] screen Object

The “screen” property of the “window” object returns the screen object, which contains the information about the user’s screen.

 

1. Properties

The “screen” object is very simple. It provides a couple of properties to retrieve user’s screen information.

  • width, height : the total width or height of the screen
  • availWidth, availHeight : available screen width or height (excluding the Windows Taskbar)
  • colorDepth : the color resolution (in bits per pixel) of the screen
  • pixelDepth : the same as colorDepth
console.log(screen.width + ", " + screen.height);
console.log(screen.availWidth + ", " + screen.availHeight);
console.log(screen.colorDepth + ", " + screen.pixelDepth);

The “colorDepth” property is identical to the “pixelDepth” property. But “pixelDepth” is supported only on IE10 or later. Meanwhile, “colorDepth”  is supported in older IE versions, too.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s