Basic Geolocation
Preview
Code
<button onclick="getLocation()">Get Location</button>
<p id="geo"></p>
<script>
function getLocation(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(pos){
document.getElementById("geo").innerText =
pos.coords.latitude + ", " + pos.coords.longitude;
});
}
}
</script>