Posted By

davebradford on 09/15/10


Tagged

geolocation


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

marshallgmoore


Geolocation


 / Published in: HTML
 

  1.  
  2. <script type="text/javascript">
  3.  
  4. if (navigator.geolocation) {
  5. navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
  6. } else {
  7. alert('Geolocation Not Support');
  8. }
  9.  
  10. function successFunction(position) {
  11. var lat = position.coords.latitude;
  12. var long = position.coords.longitude;
  13. alert('Latitude:'+lat+' Longitude:'+long);
  14. document.write (lat);
  15. document.write (long);
  16. }
  17.  
  18. function errorFunction(position) {
  19. alert('Error!');
  20. }
  21.  
  22.  
  23.  
  24. </head>
  25.  
  26. </body>
  27. </html>

Report this snippet  

You need to login to post a comment.