function success(position) { var message = document.getElementById("status"); message.innerHTML =""; message.innerHTML += "
Longitude: " + position.coords.longitude + "
"; message.innerHTML += "Latitude: " + position.coords.latitude + "
"; message.innerHTML += "Altitude: " + position.coords.altitude + "
"; } function error(msg) { var message = document.getElementById("status"); message.innerHTML = "Failed to get geolocation."; } if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(success, error); } else { error('Geolocation is not supported.'); }