【发布时间】:2019-11-29 12:53:23
【问题描述】:
我有一个页面,其中包含从设备获取当前位置并使用此代码根据位置加载其他内容的代码:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(successFunction);
} else {
// Make API call to the GeoIP services
}
它适用于我测试过的所有 android 设备,但在 iOS 和 macOS 上,它不起作用。 if 和 else 都不是。似乎它卡在获取当前位置。
有什么帮助吗?
【问题讨论】:
-
显示错误,你就会知道发生了什么-> look
navigator.geolocation.getCurrentPosition(success, error, options); -
@The Rock,您的网站是否通过 https 提供服务?
-
不,它主要在
localhost上,并且登台服务器不支持https。我在生产服务器上进行了测试,它按原样工作。
标签: javascript ios macos google-chrome safari