function showLocation(position) { var location = document.getElementById("GpsInfo"); if( location != null ) { var str = ""; str += "time:"+position.timestamp; str += "|accuracy:"+position.coords.accuracy; str += "|longitude:"+position.coords.longitude; str += "|latitude:"+position.coords.latitude; str += "|speed:"+position.coords.speed; str += "|bearing:"+position.coords.heading; str += "|altitude:"+position.coords.altitude; location.value = str; //alert(str); } } function errorHandler(error) { /*switch(error.code) { case error.PERMISSION_DENIED: alert("User denied the request for Geolocation."); break; case error.POSITION_UNAVAILABLE: alert("Location information is unavailable."); break; case error.TIMEOUT: alert("The request to get user location timed out."); break; case error.UNKNOWN_ERROR: alert("An unknown error occurred."); break; }*/ } function getLocation(){ if(navigator.geolocation){ // timeout at 60000 milliseconds (60 seconds) var options = {enableHighAccuracy:true,maximumAge:30000}; //var options = {enableHighAccuracy:true,maximumAge:30000,timeout:60000}; navigator.geolocation.getCurrentPosition(showLocation,errorHandler,options); }else{} }