Created
August 6, 2012 10:46
-
-
Save richardjpope/3273366 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script> | |
jQuery(window).ready(function(){ | |
jQuery("#btnInit").click(initiate_geolocation); | |
}); | |
function initiate_geolocation() { | |
navigator.geolocation.getCurrentPosition(handle_geolocation_query); | |
} | |
function handle_geolocation_query(position){ | |
alert('Lat: ' + position.coords.latitude + ' ' + | |
'Lon: ' + position.coords.longitude); | |
} | |
</script> | |
</head> | |
<body> | |
<div> | |
<button id="btnInit" >Find my location</button> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment