Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите сделать эту работу!
Вы можете также прочитать эту статью на English (US).

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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

DeviceLightEvent.value
The level of the ambient light in lux.

Example

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

Specifications

Specification Status Comment
Ambient Light Sensor
The definition of 'Ambient Light Events' in that specification.
Working Draft Initial specification

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support No Yes

601 2

223

No No No
value No Yes

601 2

223

No No No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support No No Yes

601 2

15

No No ?
value No No Yes

601 2

15

No No ?

1. Disabled by default. See bug 1359076.

2. From version 60: this feature is behind the device.sensors.ambientLight.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

3. Not supported for macbook with touchbar and Windows 7.

See also

Метки документа и участники

Обновлялась последний раз: connorshea,