Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 14th, 2013  |  syntax: None  |  size: 0.52 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data