PositionError

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

PositionError 接口表示当定位设备位置时发生错误的原因。

属性

PositionError 接口没有继承任何属性。

PositionError.code 只读

返回无符号的、简短的错误码。下列值是可能的:

相关联的常量 描述
1 PERMISSION_DENIED 地理位置信息的获取失败,因为该页面没有获取地理位置信息的权限。
2 POSITION_UNAVAILABLE 地理位置获取失败,因为至少有一个内部位置源返回一个内部错误。
3 TIMEOUT 获取地理位置超时,通过定义PositionOptions.timeout 来设置获取地理位置的超时时长。
PositionError.message 只读

返回一个开发者可以理解的 DOMString 来描述错误的详细信息。

方法

PositionError 接口没有实现也没有继承任何方法。

标准

Specification
Geolocation
# position_error_interface

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
GeolocationPositionError
code
message
Secure context required

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Uses a non-standard name.
Has more compatibility info.

请参见