我开发了基于html的页面,用户通过html5地理位置协调信息一分钟。但是,我第一次从Internet Explorer获得坐标。当我改变我的位置时,它不会更新。但它工作chrome和firefox。如何从IE获取坐标?
我的代码:
<!DOCTYPE html>
<html>
<body onload="timerLoc()">
<p id="demo"></p>
<script>
function timerLoc()
{
setInterval(
function(){getLocation()},3000
);
}
var x=document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition,showError);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}
function showPosition(position)
{
x.innerHTML="Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude;
}
function showError(error)
{
}
</script>
</body>
</html>