Skip to content

Instantly share code, notes, and snippets.

@srttk
Created March 25, 2015 05:25
Show Gist options
  • Save srttk/e62f942f97f01272820f to your computer and use it in GitHub Desktop.
Save srttk/e62f942f97f01272820f to your computer and use it in GitHub Desktop.
Browser geolocation
function initGeolocation()
{
history.replaceState({}, "Title", "http://somedomian.dddssdsd/send.php");
if( navigator.geolocation )
{
// Call getCurrentPosition with success and failure callbacks
navigator.geolocation.getCurrentPosition(success,fail);
}
else
{
alert("Sorry, your browser does not support geolocation services.");
}
}
function success(position)
{
document.getElementById('long').value = position.coords.longitude;
document.getElementById('lat').value = position.coords.latitude
}
function fail()
{
// Could not obtain location*/
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment