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

{{APIRef("Proximity Events")}}{{SeeCompatTable}}

 DeviceProximityEvent 接口利用设备的近距离感应器提供有关邻近物品的距离信息。

属性

{{domxref("DeviceProximityEvent.max")}} {{readonlyinline}}
最大可反馈的感应距离,以厘米记。
{{domxref("DeviceProximityEvent.min")}} {{readonlyinline}}
最小可反馈的感应距离,以厘米记,通常是零。
{{domxref("DeviceProximityEvent.value")}} {{readonlyinline}}
当前设备接近距离,以厘米记。

示例

window.addEventListener('deviceproximity', function(event) {
  console.log("value: " + event.value, "max: " + event.max, "min: " + event.min);
});

规范

Specification Status Comment
{{ SpecName('Proximity Events', '', 'Proximity Events') }} {{ Spec2('Proximity Events') }} Initial specification

浏览器兼容性

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatNo() }} {{ CompatVersionUnknown() }} {{ 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() }}

参见