Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 893995 of Screen

  • Revision slug: Web/API/Screen
  • Revision title: Screen
  • Revision id: 893995
  • Created:
  • Creator: cvrebert
  • Is current revision? Yes
  • Comment standard-table

Revision Content

{{APIRef("CSSOM View")}}

The Screen interface represents a screen, usually the one on which the current window is being rendered.

Usually it is the one on which the current window is being rendered, obtained using window.screen.

Properties

{{domxref("Screen.availTop")}}
Specifies the y-coordinate of the first pixel that is not allocated to permanent or semipermanent user interface features.
{{domxref("Screen.availLeft")}}
Returns the first available pixel available from the left side of the screen.
{{domxref("Screen.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("Screen.availWidth")}}
Returns the amount of horizontal space in pixels available to the window.
{{domxref("Screen.colorDepth")}}
Returns the color depth of the screen.
{{domxref("Screen.height")}}
Returns the height of the screen in pixels.
{{domxref("Screen.left")}}
Returns the distance in pixels from the left side of the main screen to the left side of the current screen.
{{domxref("Screen.orientation")}}
Returns the current orientation of the screen.
{{domxref("Screen.pixelDepth")}}
Gets the bit depth of the screen.
{{domxref("Screen.top")}}
Returns the distance in pixels from the top side of the current screen.
{{domxref("Screen.width")}}
Returns the width of the screen.
{{domxref("Screen.mozEnabled")}} {{gecko_minversion_inline("12.0")}}
Boolean. Setting to false will turn off the device's screen.
{{domxref("Screen.mozBrightness")}} {{gecko_minversion_inline("12.0")}}
Controls the brightness of a device's screen. A double between 0 and 1.0 is expected.

Events handler

{{domxref("Screen.onorientationchange")}}
A handler for the {{event("orientationchange")}} events.

Methods

{{domxref("Screen.lockOrientation")}}
Lock the screen orientation (only works in fullscreen or for installed apps)
{{domxref("Screen.unlockOrientation")}}
Unlock the screen orientation (only works in fullscreen or for installed apps)

Methods inherit from {{domxref("EventTarget")}}

{{page("/en-US/docs/Web/API/EventTarget","Methods")}}

Example

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

Specification

Specification Status Comment
{{ SpecName('CSSOM View', '#the-screen-interface', 'Screen') }} {{ Spec2('CSSOM View') }}  

Revision Source

<div>{{APIRef("CSSOM View")}}</div>

<p>The <code>Screen</code> interface represents a screen, usually the one on which the current window is being rendered.</p>

<p>Usually it is the one on which the current window is being rendered, obtained using <code>window.screen</code>.</p>

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

<dl>
 <dt>{{domxref("Screen.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("Screen.availLeft")}}</dt>
 <dd>Returns the first available pixel available from the left side of the screen.</dd>
 <dt>{{domxref("Screen.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("Screen.availWidth")}}</dt>
 <dd>Returns the amount of horizontal space in pixels available to the window.</dd>
 <dt>{{domxref("Screen.colorDepth")}}</dt>
 <dd>Returns the color depth of the screen.</dd>
 <dt>{{domxref("Screen.height")}}</dt>
 <dd>Returns the height of the screen in pixels.</dd>
 <dt>{{domxref("Screen.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("Screen.orientation")}}</dt>
 <dd>Returns the current orientation of the screen.</dd>
 <dt>{{domxref("Screen.pixelDepth")}}</dt>
 <dd>Gets the bit depth of the screen.</dd>
 <dt>{{domxref("Screen.top")}}</dt>
 <dd>Returns the distance in pixels from the top side of the current screen.</dd>
 <dt>{{domxref("Screen.width")}}</dt>
 <dd>Returns the width of the screen.</dd>
 <dt>{{domxref("Screen.mozEnabled")}} {{gecko_minversion_inline("12.0")}}</dt>
 <dd>Boolean. Setting to false will turn off the device's screen.</dd>
 <dt>{{domxref("Screen.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>

<h3 id="Events_handler">Events handler</h3>

<dl>
 <dt>{{domxref("Screen.onorientationchange")}}</dt>
 <dd>A handler for the {{event("orientationchange")}} events.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<dl>
 <dt>{{domxref("Screen.lockOrientation")}}</dt>
 <dd>Lock the screen orientation (only works in fullscreen or for installed apps)</dd>
 <dt>{{domxref("Screen.unlockOrientation")}}</dt>
 <dd>Unlock the screen orientation (only works in fullscreen or for installed apps)</dd>
</dl>

<p>Methods inherit from {{domxref("EventTarget")}}</p>

<p>{{page("/en-US/docs/Web/API/EventTarget","Methods")}}</p>

<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="Specification" name="Specification">Specification</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('CSSOM View', '#the-screen-interface', 'Screen') }}</td>
   <td>{{ Spec2('CSSOM View') }}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
Revert to this revision