--- title: AmbientLightSensor slug: Web/API/AmbientLightSensor translation_of: Web/API/AmbientLightSensor ---

{{SeeCompatTable}}{{APIRef("Ambient Light Sensor API")}}

环境光传感器API的``AmbientLightSensor``返回一个用于访问{{domxref('AmbientLightSensorReading')}}的接口。

实例

{{domxref("AmbientLightSensor.AmbientLightSensor()")}}
创建一个新的 AmbientLightSensor 对象.

属性

{{domxref('AmbientLightSensor.reading')}}
返回一个 {{domxref('AmbientLightSensorReading')}} 接口, 包含当前光的亮度级别。

Examples

// TBD
Specification Status Comment
{{SpecName('AmbientLight','#ambient-light-sensor-interface','AmbientLightSensor')}} {{Spec2('AmbientLight')}} Initial definition.

浏览器兼容性

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatChrome(54.0)}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatChrome(54.0)}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatChrome(54.0)}}