我有这个页面加载一次很好......
基本上它正在拉一个gps位置,然后我希望它每10秒进行一次重定向以再次拉取gps数据......
但它不会每 10 秒不断重定向...
怎么了-从外观上看它应该...
<script type="text/javascript">
// Get a single location update
function getLocationConstant()
{
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoError,{enableHighAccuracy:true,maximumAge:0});
} else {
alert("Your browser or device doesn't support Geolocation");
}
}
// If we have a successful location update
function onGeoSuccess(event)
{
document.getElementById("Latitude").value = event.coords.latitude;
document.getElementById("Longitude").value = event.coords.longitude;
document.getElementById("location").href = "track2.cfm?track=s&GPSLat=" + event.coords.latitude + "&GPSLong=" + event.coords.longitude;
redirectUrl = "track2.cfm?track=y&GPSLat=" + event.coords.latitude + "&GPSLong=" + event.coords.longitude;
gpslat = event.coords.latitude;
gpslong = event.coords.longitude;
}
// If something has gone wrong with the geolocation request
function onGeoError(event)
{
alert("Error code " + event.code + ". " + event.message);
}
function redirect()
{
window.location = redirectUrl;
}
setTimeout(redirect,10000);
</script>