Microsoft Edge 一直显示消息 'User denied request for Geolocation' 即使我已为站点启用位置
Microsoft Edge keeps showing message 'User denied request for Geolocation' even when I have enabled location for the site
我开发了一个应用程序,可以在单击按钮时保存用户事件和位置。此应用程序可在除 Microsoft Edge 之外的其他浏览器上完美运行。
如果用户一次拒绝地理定位请求并希望下次允许,那么即使在清除缓存、启用位置和管理设置中的权限之后,每次单击按钮时都会继续出现警报 'User denied request for Geolocation'。有什么意见、类似的经验和解决方案吗?
function button_click(){
showPosition();
}
function showPosition(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(successCallback,
errorCallback, options);
} else {
alert('Geolocation not supported by your browser');
document.cookie = "latitude=0.0";
document.cookie = "longitude=0.0";
document.getElementById("myForm").submit();
}
}
var options = {
enableHighAccuracy: true,
// timeout: 10000,
maximumAge: 0
};
function successCallback(position){
var latitude = position.coords.latitude.toFixed(5);
var longitude = position.coords.longitude.toFixed(5);
document.cookie = "latitude=" + latitude;
document.cookie = "longitude=" + longitude;
document.getElementById("myForm").submit();
}
function errorCallback(error){
switch (error.code){
case error.PERMISSION_DENIED:
alert("User denied request for Geolocation.");
break;
case error.POSITION_UNAVAILABLE:
alert("Location information is not available.");
break;
case error.TIMEOUT:
alert("The request to get user location timed out.");
break;
default:
alert("Unkown error.");
}
document.cookie = "latitude=0.0";
document.cookie = "longitude=0.0";
document.getElementById("myForm").submit();
}
我不希望警报 'User denied request for Geolocation' 每次都出现,即使在用户启用位置后也是如此。
我尝试在 Microsoft Edge 44.17763.1.0
上使用您的代码进行测试
根据我的测试结果,在用户拒绝首次共享位置后,每次都会显示警报 'User denied request for Geolocation'。
原因是 MS Edge 会记住用户的选择,不会再次提示用户共享位置。
如果用户想要分享位置而不是
(1) 用户需要转到 设置和更多 -> 设置 -> 高级 -> 管理权限
(2) Select 列表中的站点并单击它。
(3) 打开位置切换按钮。
之后就可以正常工作了,不会显示错误信息了。
我开发了一个应用程序,可以在单击按钮时保存用户事件和位置。此应用程序可在除 Microsoft Edge 之外的其他浏览器上完美运行。 如果用户一次拒绝地理定位请求并希望下次允许,那么即使在清除缓存、启用位置和管理设置中的权限之后,每次单击按钮时都会继续出现警报 'User denied request for Geolocation'。有什么意见、类似的经验和解决方案吗?
function button_click(){
showPosition();
}
function showPosition(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(successCallback,
errorCallback, options);
} else {
alert('Geolocation not supported by your browser');
document.cookie = "latitude=0.0";
document.cookie = "longitude=0.0";
document.getElementById("myForm").submit();
}
}
var options = {
enableHighAccuracy: true,
// timeout: 10000,
maximumAge: 0
};
function successCallback(position){
var latitude = position.coords.latitude.toFixed(5);
var longitude = position.coords.longitude.toFixed(5);
document.cookie = "latitude=" + latitude;
document.cookie = "longitude=" + longitude;
document.getElementById("myForm").submit();
}
function errorCallback(error){
switch (error.code){
case error.PERMISSION_DENIED:
alert("User denied request for Geolocation.");
break;
case error.POSITION_UNAVAILABLE:
alert("Location information is not available.");
break;
case error.TIMEOUT:
alert("The request to get user location timed out.");
break;
default:
alert("Unkown error.");
}
document.cookie = "latitude=0.0";
document.cookie = "longitude=0.0";
document.getElementById("myForm").submit();
}
我不希望警报 'User denied request for Geolocation' 每次都出现,即使在用户启用位置后也是如此。
我尝试在 Microsoft Edge 44.17763.1.0
上使用您的代码进行测试根据我的测试结果,在用户拒绝首次共享位置后,每次都会显示警报 'User denied request for Geolocation'。
原因是 MS Edge 会记住用户的选择,不会再次提示用户共享位置。
如果用户想要分享位置而不是
(1) 用户需要转到 设置和更多 -> 设置 -> 高级 -> 管理权限
(2) Select 列表中的站点并单击它。
(3) 打开位置切换按钮。
之后就可以正常工作了,不会显示错误信息了。