Html geoLocation.GetCurrentPosition在IE 11中总是失败
下面的脚本在FireFox和Chrome中运行良好,但在InternetExplorer11中,它总是失败(位置_不可用) 我已将浏览器设置为允许职位请求,并且我同意浏览器在请求权限时向我显示的提示 我几乎可以肯定,几个月前,当我最后一次尝试它时,它工作得很好。就IE的设置而言,我可能缺少什么Html geoLocation.GetCurrentPosition在IE 11中总是失败,html,internet-explorer,geolocation,internet-explorer-11,Html,Internet Explorer,Geolocation,Internet Explorer 11,下面的脚本在FireFox和Chrome中运行良好,但在InternetExplorer11中,它总是失败(位置_不可用) 我已将浏览器设置为允许职位请求,并且我同意浏览器在请求权限时向我显示的提示 我几乎可以肯定,几个月前,当我最后一次尝试它时,它工作得很好。就IE的设置而言,我可能缺少什么 <script type="text/javascript"> $(document).ready(function () { if (Modernizr.geoloc
<script type="text/javascript">
$(document).ready(function () {
if (Modernizr.geolocation)
{
navigator.geolocation.getCurrentPosition(positionSuccess, positionError, { enableHighAccuracy: true, maximumAge: 60000, timeout: 10000 })
}
else
{
$("#GeoError").html("Unable to retrieve current position.")
}
});
function positionSuccess(position)
{
$("#Latitude").val(position.coords.latitude);
$("#Longitude").val(position.coords.longitude);
}
function positionError(error)
{
var message = "";
// Check for known errors
switch (error.code) {
case error.PERMISSION_DENIED:
message = "This website does not have your permission to use the Geolocation API";
break;
case error.POSITION_UNAVAILABLE:
message = "Your current position could not be determined.";
break;
case error.PERMISSION_DENIED_TIMEOUT:
message = "Your current position could not be determined within the specified timeout period.";
break;
}
// If it's an unknown error, build a message that includes
// information that helps identify the situation, so that
// the error handler can be updated.
if (message == "") {
var strErrorCode = error.code.toString();
message = "Your position could not be determined due to " +
"an unknown error (Code: " + strErrorCode + ").";
}
$("#GeoError").html(message)
}
</script>
$(文档).ready(函数(){
if(现代化地理定位)
{
navigator.geolocation.getCurrentPosition(positionSuccess,positionError,{EnableHighAccurance:true,maximumAge:60000,timeout:10000})
}
其他的
{
$(“#GeoError”).html(“无法检索当前位置。”)
}
});
职能职位成功(职位)
{
$(“#纬度”).val(位置坐标纬度);
$(“#经度”).val(位置.坐标.经度);
}
功能位置错误(错误)
{
var message=“”;
//检查已知错误
开关(错误代码){
案例错误。权限被拒绝:
message=“此网站没有您使用地理定位API的权限”;
打破
案例错误。位置不可用:
message=“无法确定您当前的职位。”;
打破
案例错误。权限被拒绝\u超时:
message=“无法在指定的超时时间内确定您的当前位置。”;
打破
}
//如果是未知错误,请生成包含以下内容的消息
//有助于确定情况的信息,以便
//可以更新错误处理程序。
如果(消息==“”){
var strErrorCode=error.code.toString();
message=“由于以下原因,无法确定您的职位”+
未知错误(代码:“+strErrorCode+”);
}
$(“#GeoError”).html(消息)
}
此外,我在IE11中尝试时也遇到了同样的失败,FireFox和Chrome都可以正常工作。在Internet选项中,单击隐私选项卡。取消选中“永不允许网站请求您的物理位置”框,点击“确定”
在做了这些改变之后,我的工作现在开始了。起初没有。我只在IE11中遇到过同样的问题。
我必须将enableHighAccurance设置为false才能使其工作。一旦我做到了,IE就如预期的那样工作。您是否启用了定位服务 我也遇到过同样的问题,在我在windows 2016中启用了位置服务后,问题就解决了
啊哈,刚刚发现了一些东西。 Chrome显然使用WIFI接入点来帮助查找位置
如果没有即时GPS信号,IE11(和edge)将返回到windows设置中的默认位置。能否显示脚本引用?不确定“脚本引用”是什么意思。我确实在页面顶部引用了modernizr-2.8.3.js的本地副本,以及jquery-2.1.3.js、bootstrap.js和respond.js的本地副本,就在上面显示的脚本之前。我遇到的问题并不局限于我的代码。你有没有发现这个问题?我也有同样的问题,但我找不到解决方案。我对IE11也有同样的问题-有人知道解决方案吗?如果你有这个问题,但这个问题还没有找到答案,请投票表决。“绝不允许网站请求你的物理位置”已经取消选中。如原问题中所述,浏览器已设置为允许位置请求,并请求我的许可,但无论如何都失败。尝试了所有这些解决方案。不走运。我将EnableHighAccurance设置为false,但它不起作用。我的IE版本是11.1715.14393.0。