1. function getCurrentPosition() {
  2.  
  3. if (navigator.geolocation)
  4. {
  5. navigator.geolocation.getCurrentPosition(
  6.  
  7. function( position ) {
  8. alert(position.coords.latitude + ', ' +position.coords.longitude);
  9. },
  10.  
  11. function( error ) {
  12. alert( "Something went wrong: ", error );
  13. },
  14.  
  15. {
  16. timeout: (10 * 1000)
  17. }
  18.  
  19. );
  20.  
  21. }
  22. else {
  23. alert("Geolocation is not supported by this browser.");
  24. }
  25. }