Created
March 25, 2015 05:25
-
-
Save srttk/e62f942f97f01272820f to your computer and use it in GitHub Desktop.
Browser geolocation
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
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