Window.screen

  • Revision slug: Web/API/window.screen
  • Revision title: window.screen
  • Revision id: 407275
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment Moved From DOM/window.screen to Web/API/window.screen

Revision Content

{{DomRef}}

Summary

Returns a reference to the screen object associated with the window.

Syntax

screenObj = window.screen;

Example

if (screen.pixelDepth < 8) {
  // use low-color version of page
} else { 
  // use regular, colorful page
}

Notes

The screen object is a special object for inspecting properties of the screen on which the current window is being rendered.

This object has the following properties:

{{domxref("window.screen.availTop", "availTop")}}
Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
{{domxref("window.screen.availLeft", "availLeft")}}
Returns the first available pixel available from the left side of the screen.
{{domxref("window.screen.availHeight", "availHeight")}}
Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows.
{{domxref("window.screen.availWidth", "availWidth")}}
Returns the amount of horizontal space in pixels available to the window.
{{domxref("window.screen.colorDepth", "colorDepth")}}
Returns the color depth of the screen.
{{domxref("window.screen.height", "height")}}
Returns the height of the screen in pixels.
{{domxref("window.screen.left", "left")}}
Returns the distance in pixels from the left side of the main screen to the left side of the current screen.
{{domxref("window.screen.pixelDepth", "pixelDepth")}}
Gets the bit depth of the screen.
{{domxref("window.screen.top", "top")}}
Returns the distance in pixels from the top side of the current screen.
{{domxref("window.screen.width", "width")}}
Returns the width of the screen.
{{domxref("window.screen.lockOrientation", "lockOrientation")}}
Lock the screen orientation (only works in fullscreen or for installed apps)
{{domxref("window.screen.unlockOrientation", "unlockOrientation")}}
Unlock the screen orientation (only works in fullscreen or for installed apps)
{{domxref("window.screen.mozEnabled", "mozEnabled")}} {{gecko_minversion_inline("12.0")}}
Boolean. Setting to false will turn off the device's screen.
{{domxref("window.screen.mozBrightness", "mozBrightness")}} {{gecko_minversion_inline("12.0")}}
Controls the brightness of a device's screen. A double between 0 and 1.0 is expected.

Specification

{{DOM0}}

Revision Source

<div>{{DomRef}}</div>


<h2 id="Summary" name="Summary">Summary</h2>
<p>Returns a reference to the screen object associated with the window.</p>


<h2 id="Syntax" name="Syntax">Syntax</h2>


<pre class="syntaxbox">
<var>screenObj</var> = <var>window</var>.screen;
</pre>

<h2 id="Example" name="Example">Example</h2>

<pre class="brush:js">
if (screen.pixelDepth &lt; 8) {
  // use low-color version of page
} else { 
  // use regular, colorful page
}
</pre>


<h2 id="Notes" name="Notes">Notes</h2>

<p>The <code>screen</code> object is a special object for inspecting properties of the screen on which the current window is being rendered.</p>
<p>This object has the following properties:</p>
<dl>
  <dt>{{domxref("window.screen.availTop", "availTop")}}</dt>
  <dd>Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.</dd>
  <dt>{{domxref("window.screen.availLeft", "availLeft")}}</dt>
  <dd>Returns the first available pixel available from the left side of the screen.</dd>
  <dt>{{domxref("window.screen.availHeight", "availHeight")}}</dt>
  <dd>Specifies the height of the screen, in pixels, minus permanent or semipermanent user interface features displayed by the operating system, such as the Taskbar on Windows.</dd>
  <dt>{{domxref("window.screen.availWidth", "availWidth")}}</dt>
  <dd>Returns the amount of horizontal space in pixels available to the window.</dd>
  <dt>{{domxref("window.screen.colorDepth", "colorDepth")}}</dt>
  <dd>Returns the color depth of the screen.</dd>
  <dt>{{domxref("window.screen.height", "height")}}</dt>
  <dd>Returns the height of the screen in pixels.</dd>
  <dt>{{domxref("window.screen.left", "left")}}</dt>
  <dd>Returns the distance in pixels from the left side of the main screen to the left side of the current screen.</dd>
  <dt>{{domxref("window.screen.pixelDepth", "pixelDepth")}}</dt>
  <dd>Gets the bit depth of the screen.</dd>
  <dt>{{domxref("window.screen.top", "top")}}</dt>
  <dd>Returns the distance in pixels from the top side of the current screen.</dd>
  <dt>{{domxref("window.screen.width", "width")}}</dt>
  <dd>Returns the width of the screen.</dd>
  <dt>{{domxref("window.screen.lockOrientation", "lockOrientation")}}</dt>
  <dd>Lock the screen orientation (only works in fullscreen or for installed apps)</dd>
  <dt>{{domxref("window.screen.unlockOrientation", "unlockOrientation")}}</dt>
  <dd>Unlock the screen orientation (only works in fullscreen or for installed apps)</dd>
  <dt>{{domxref("window.screen.mozEnabled", "mozEnabled")}} {{gecko_minversion_inline("12.0")}}</dt>
  <dd>Boolean. Setting to false will turn off the device's screen.</dd>
  <dt>{{domxref("window.screen.mozBrightness", "mozBrightness")}} {{gecko_minversion_inline("12.0")}}</dt>
  <dd>Controls the brightness of a device's screen. A double between 0 and 1.0 is expected.</dd>
</dl>
<h2 id="Specification" name="Specification">Specification</h2>
<p>{{DOM0}}</p>
Revert to this revision