How do i reset the geo-location service settings e

2019-06-14 15:26发布

问题:

I am working on a web page where I need to get permission from a user to access location.

but according to my story. I need to make sure that if any particular user has selected Deny previously then on each page load I need to show him a prompt saying

[website] want to use your computer's location as shown in the snapshot below:

But on the other hand, if the user has selected Allow it should not prompt anymore.

Is there any easy and straightforward way to achieve this functionality with JS or HTML5 settings? If not then what else I could do in order to achieve this functionality?

回答1:

This is not possible.

See: How to make Google Maps to request again for location permissions?

The browser handles this and once a choice has been made, you cannot reverse it. If your site requires geolocation to work, you can always check if the permission is given (see here: Is there a way to check if geolocation has been DECLINED with Javascript?) and if not, you should change the content or behaviour of the site, so your users know what's going on.