Yaq*_*mad 2 internet-explorer geolocation
我正在尝试使用geolocation api时遇到此错误:
This website does not have permission to use the Geolocation API
Run Code Online (Sandbox Code Playgroud)
奇怪的是,同一个网站在某些系统(安装了IE.9和I.E10)上运行良好,并且在安装IE 9的系统上抛出错误.
我们在不同的系统上测试了它,但它只在安装了I.E9的特定系统上抛出错误.
代码:
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");
}
}
Run Code Online (Sandbox Code Playgroud)
如果成功:
function geolocationSuccess(position) {
var userCurrentLatLong = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
}
Run Code Online (Sandbox Code Playgroud)
如果有错误:
function geolocationError(positionError) {
alert(positionError.message + "\n" + "you will be redirected to default location.");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5936 次 |
| 最近记录: |