Animations

API

Arrays

Async

Basics

Challenges

Classes

Console

Dates

Debugging

DOM Elements

DOM Methods

DOM Navigation

DOM Properties

Event Listeners

Flow Control

Forms

Functions

Global Functions

JSON

Keywords

Libraries (3rd party)

Math

Modules

Objects

Snippets

String

Types

Widgets

Window Object

JavaScript - Window Screen

The window.screen object contains information about the user's screen (resolution). Technically, this can be called and written without the "window" prefix but since it is actually part of the window object, I’m including it here.

The screen object contains several properties:

  • window.screen.width
  • window.screen.height
  • window.screen.availWidth
  • window.screen.availHeight
  • window.screen.colorDepth
  • window.screen.pixelDepth

let output = "";
let Screen =
{
    ScreenWidth: window.screen.width,
    ScreenHeight: window.screen.height,
    AvailWidth: window.screen.availWidth,
    AvailHeight: window.screen.availHeight,
    ColorDepth: window.screen.colorDepth,
    PixelDepth: window.screen.pixelDepth
};

output += "screenWidth: " + Screen.ScreenWidth + "<br />";
output += "screenHeight: " + Screen.ScreenHeight + "<br />";
output += "availWidth: " + Screen.AvailWidth + "<br />";
output += "availHeight: " + Screen.AvailHeight + "<br />";
output += "colorDepth: " + Screen.ColorDepth + "<br />";
output += "pixelDepth: " + Screen.PixelDepth + "<br />";

document.getElementById("demo1").innerHTML = output;