Advertisement
Guest User

nodejs geolocation html5

a guest
Nov 24th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <p id="demo"></p>
  6.  
  7. <script>
  8.  
  9. getLocation();
  10.  
  11. var x = document.getElementById("demo");
  12.  
  13. function getLocation() {
  14.     if (navigator.geolocation) {
  15.         navigator.geolocation.watchPosition(showPosition);
  16.     } else {
  17.         x.innerHTML = "Geolocation is not supported by this browser.";}
  18.     }
  19.    
  20. function showPosition(position) {
  21.     x.innerHTML="Latitude: " + position.coords.latitude +
  22.     "<br>Longitude: " + position.coords.longitude; 
  23. }
  24. </script>
  25.  
  26. </body>
  27. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement