Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 480 Bytes

geolocation.md

File metadata and controls

25 lines (19 loc) · 480 Bytes

Geolocation

<script>
var x = document.getElementById("demo");
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}
function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude; 
}
</script>