Get geolocation coordinates HTML5 Geolocation – HTML Examples


Get geolocation coordinates HTML5 Geolocation – HTML Examples

 

 
 
  1. <button onclick="getLocation()">Try It</button>
  2. <p id="demo"></p>
  3. <script>
  4. var x = document.getElementById("demo");
  5. function getLocation() {
  6. if (navigator.geolocation) {
  7. navigator.geolocation.getCurrentPosition(showPosition);
  8. } else {
  9. x.innerHTML = "Geolocation is not supported by this browser.";
  10. }
  11. }
  12. function showPosition(position) {
  13. x.innerHTML = "Latitude: " + position.coords.latitude +
  14. "<br>Longitude: " + position.coords.longitude;
  15. }
  16. </script>

 

Try Your Self ->

 


Source: w3schools.com

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Website

Wordpress  Create Free Website (Web Builder)
Uploadfile  Upload File Website (Unlimited)
Mobilelist  Mobile Price Website (Mobilelop)
Blog  Create Blog Website (Wapfo)
Wapbuilder  Create Free Wapsite (Wapbuilder)
"