Reputation:
Is it possible to attach event to browser geolocation request state?
When bar is visible show arrow to user... something like this:
Upvotes: 2
Views: 1022
Reputation: 1
Be aware that navigator.geolocation
returns false
in case the browser itself doesn't support the geolocation API. It has noting to do with permissions the user might (or might not) give to the site to access his/her location.
For further information, I suggest reading this html5doctor.com article.
Upvotes: -1
Reputation: 417
BTW, You're going down a dark path of having to have a different help text for various versions of browsers/types/etc.
For instance, Firefox 29.0.1 permission window:
In any event, I would suggest a variation of Nerdicus recommendation:
Instead of defaulting to show the arrow & then just hiding it when the JavaScript gets called, I would default display: none;, and then trigger a .show() right before you make the geolocation request to reduce your "flicker", and then hide it in your success/error callback.
Additionally, in your success handler, you can create a cookie (probably at the session level)
$.cookie("geoperm", "true")
Then you can check for existing permissions before showing the tooltip:
if (navigator.geolocation) {
// Show the arrow here, but only if there isn't a cookie stating we have permissions
if(!$.cookie("geoperm")) $("#geo-helper").show();
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
Upvotes: 2
Reputation: 158
You could always detect whether the user allows / deny's geolocation, and from there, hide the large arrow pointing to the accept/deny prompt.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
Upvotes: 0