本网站无权使用Geolocation API

时间:2013-04-01 11:53:49

标签: internet-explorer geolocation

我在尝试使用geolocation api时遇到此错误:

This website does not have permission to use the Geolocation API

奇怪的是,同一个网站在某些系统上运行良好(安装了 IE.9和I.E10 )并且在 IE 9的系统上抛出错误已安装。

我们在不同系统上对其进行了测试,但仅在安装了 I.E9 的特定系统上引发错误。

  • 我们是否需要一些浏览器设置才能使用此API?
  • 我们的网站要求使用地理定位API的持续时间是什么?

代码

function geolocateUser()
{
    // If the browser supports the Geolocation API
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError);
    }
    else {
        alert("Your browser doesn't support the Geolocation API");
    }

}

如果成功:

function geolocationSuccess(position) {

    var userCurrentLatLong = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);



}

如果出现错误:

function geolocationError(positionError) {

    alert(positionError.message + "\n" + "you will be redirected to default location.");


}

4 个答案:

答案 0 :(得分:6)

这可能是Windows设置,至少在我的情况下。尝试转到“设置”(从Windows的“开始”菜单中搜索)>隐私>位置和转弯位置=开。

答案 1 :(得分:1)

按照以下IE的说明进行操作:

  • 打开工具>>互联网选项>>见下图

enter image description here

答案 2 :(得分:0)

对于Windows 10,您可能需要打开"位置服务"在设置>隐私>在Internet Explorer中打开它之前的位置。

请参阅:Windows 10 location service and privacy

答案 3 :(得分:-1)

请注意,如果您在开发移动应用时在Windows手机中遇到此问题,则网站应为:“http://www.geo.com/geo”。如果域名是某个IP地址,请说:“192.168.1.2”,即“http://192.168.1.2/geo”,您永远无法通过它!