【发布时间】:2022-02-01 19:57:54
【问题描述】:
我尝试在 IE11 上使用 HTML5 Geolocation,但尽管允许位置权限,但我收到错误消息“此站点无权使用 Geolocation API。”
复制:
- 在 IE11 中打开任何网站(我是用户 browerstack 来模拟 Windows 10)
- 在控制台中复制/粘贴以下代码:
var options = {
enableHighAccuracy: false,
timeout: 1000000,
maximumAge: 0
};
function success(pos) {
var crd = pos.coords;
console.log('got your position');
}
function error(err) {
console.log(err);
}
navigator.geolocation.getCurrentPosition(success, error, options);
- 出现位置提示时单击“允许一次”
- 观察Resulting Error Message,
"This site does not have permission to use the Geolocation API."
我的浏览器堆栈在 Windows 10 上运行 IE11 版本 11.1.17134.0。
提前感谢您的帮助!
【问题讨论】:
-
我可以在 IE 11 中重现该问题。我认为这是因为 IE 不支持Secure context required。地理位置仅在安全环境中可用。此外,IE 11 即将退役,我建议您可以使用现代浏览器来代替。
标签: geolocation internet-explorer-11