Navigator.geolocation
Navigator.geolocation
只读属性返回一个 Geolocation
对象,通过这个对象可以访问到设备的位置信息。使网站或应用可以根据用户的位置提供个性化结果。
注意: 出于安全考虑,当网页请求获取用户位置信息时,用户会被提示进行授权。注意不同浏览器在请求权限时有不同的策略和方式。Windows10在未开启定位的情况下无法获取位置
语法
geo = navigator.geolocation
标准
标准 | 状态 | 备注 |
---|---|---|
Geolocation API NavigatorGeolocation.geolocation |
Recommendation | 初次定义 |
浏览器兼容性
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)