Ok so I've got code like the following:
navigator.geolocation.getCurrentPosition (
function (e) {
alert('ok');
}, function (e) {
alert('denied');
}
);
I could call this on pageload, and if the permission is denied, I'll hide the buttons and functionality that rely on having geoloc information.
However, I don't want to request the permission on pageload, but only on demand, when a user chooses to click one of the geoloc buttons.
So in this scenario, supposing that a user arrives on my page, having previously decided to deny access to the geolocation API, is it possible to tell that the permission has been previously denied so that I can hide the buttons without having to wait until they click one of the buttons again?
Do you mean denied access to another website, or previously on your website?
If the former, why assume you are subject to that decision? That is, don't worry about it and ask again anyway.
If the latter, you probably ought to store the decision for the duration of the user's session on your site. You could do this server-side if you are using server sessions, or with simple cookies.