Navigator:geolocation 属性

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.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

Navigator.geolocation 只读属性返回 Geolocation 对象,该对象允许 Web 内容访问设备的位置。这允许网站或应用程序根据用户的位置提供定制化的结果。

备注: 出于安全考虑,当网页请求获取用户位置信息时,用户会被提示进行授权。注意,不同浏览器在请求权限时有不同的策略和方式。

一个 Geolocation 对象。

规范

Specification
Geolocation
# dom-navigator-geolocation

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
geolocation
Secure context required

Legend

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

Full support
Full support
No support
No support

参见