Saturday, 18 May 2013

Your GEO LOCATION

Hi!! friends today i will show how to get your geo location using html coding . All you need to have is notepad and a web browser (mozilla firefox, safari, internet explorer etc) . Write the following html code in notepad and save the file as location.html
<!DOCTYPE html>
<html>
<body>
<p id="demo">Click the button to get your locations:</p>
<button onclick="getLocation()">Try It</button>
<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>
</body>
</html>


Save the file as location.html
Run the file to get your coordinates


No comments:

Post a Comment