geolocation.getCurrentPosition
Failure response is cached when user updates their location settings, unless the page is refreshed.
by Duncan Cumming
HTML
<a href="" id="clickme">Click Me</a>
JavaScript
$(document).ready(function() {
$('#clickme').on('click', function() {
navigator.geolocation.getCurrentPosition(
function() {
console.log('success');
},
function(error) {
console.log('failure');
},
{
timeout: 5000,
maximumAge: 0,
enableHighAccuracy: true
}
);
return false;
});
});