html 5 location
Posted: Wed Feb 25, 2015 9:44 pm
trying to figure out why this code clears the page as drawn, and then shows the location fine
Code: Select all
<script>
//var x;
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
document.write("Geolocation is not supported by this browser.");
document.writeln();
}
}
function showPosition(position) {
document.write("Latitude: " + position.coords.latitude +
"<br />Longitude: " + position.coords.longitude);
document.writeln();
}
document.write(showPosition(getLocation()));
document.writeln();
</script>