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 376829 of DeviceLightEvent

  • Revision slug: DOM/DeviceLightEvent
  • Revision title: DeviceLightEvent
  • Revision id: 376829
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment

Revision Content

{{DomRef}}

Summary

The DeviceLightEvent provides web developers with information from photo sensors or similiar detectors about ambient light levels near the device. For example this may be useful to adjust the screen's brightness based on the current ambient light level in order to save energy or provide better readability.

Properties

{{domxref("DeviceLightEvent.value")}}
The level of the ambient light in lux.

Example

window.addEventListener('devicelight', function(event) {
  console.log(event.value);
});

Specifications

Specification Status Comment
{{ SpecName('AmbientLight', '', 'Ambient Light Events') }} {{ Spec2('AmbientLight') }} Initial specification

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatNo() }} {{ CompatGeckoDesktop("22.0") }} (Mac OS X only) {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatNo() }} {{ CompatNo() }} {{ CompatGeckoMobile("15.0") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}

Gecko-specific notes

The {{event("devicelight")}} event is implemented and preference enabled by default in Firefox Mobile for Android (15.0) and in Firefox OS (B2G). Starting with Gecko 22.0 {{geckoRelease("22.0")}} a desktop implementation for Mac OS X is also available. Support for Windows 7 is in progress (see {{bug(754199)}}).

See also

  • {{ domxref("LightLevelEvent") }}

Revision Source

<p>{{DomRef}}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>DeviceLightEvent</code> provides web developers with information from photo sensors or similiar detectors about ambient light levels near the device. For example this may be useful to adjust the screen's brightness based on the current ambient light level in order to save energy or provide better readability.</p>
<h2 id="Properties">Properties</h2>
<dl>
  <dt>
    {{domxref("DeviceLightEvent.value")}}</dt>
  <dd>
    The level of the ambient light in <a href="https://en.wikipedia.org/wiki/Lux" title="https://en.wikipedia.org/wiki/Lux">lux</a>.</dd>
</dl>
<h2 id="Example">Example</h2>
<pre>
window.addEventListener('devicelight', function(event) {
&nbsp; console.log(event.value);
});</pre>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table" height="49" width="1000">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ SpecName('AmbientLight', '', 'Ambient Light Events') }}</td>
      <td>{{ Spec2('AmbientLight') }}</td>
      <td>Initial specification</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatGeckoDesktop("22.0") }} (Mac OS X only)</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Chrome for Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatGeckoMobile("15.0") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<h3 id="Gecko-specific_notes">Gecko-specific notes</h3>
<p>The {{event("devicelight")}} event is implemented and preference enabled by default in Firefox Mobile for Android (15.0) and in Firefox OS (B2G). Starting with Gecko 22.0 {{geckoRelease("22.0")}} a desktop implementation for Mac OS X is also available. Support for Windows 7 is in progress (see {{bug(754199)}}).</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{ domxref("LightLevelEvent") }}</li>
</ul>
Revert to this revision