I’m using this https://github.com/remy/html5demos/blob/master/demos/geo.html plug in.
If a user has blocked to share his location or if a user uses this in a un supported browser,
I want to show him a text box.
How can this be done in this code?
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
window.getElementById('idOfTextInput').value = message
}
There is a if else loop,that will show the error
That’s the
errorpart in this code.If the Geolocation API is not supported at all (
if (!navigator.geolocation)), theerror('not supported')is executed. Furthermore thegetCurrentPositionmethod takes two callbacks:successanderror. Thesuccesscallback is called when the location request was successful, theerrorcallback is called when it was not.