{{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") }}