Make html5 geolocation ask permission every time user reloads the page

前端 未结 1 1995
遥遥无期
遥遥无期 2020-12-29 13:21

Why we need that:

We have some page in our website which allows users to enter some data and search for another customers in their area. When user opened th

相关标签:
1条回答
  • 2020-12-29 14:00

    once a user clicks deny/allow the browser remembers this decision for the site.

    the best way to avoid a deny is to only call getCurrentPosition(...) when the user clicked something that means he wants to use his location. and then he would probably be glad to share it :)

    A good example is on foursquare site. on entering it offers you to go to the map to some city, and only there by clicking the button on the map of "use my location" it prompts for it.

    If you are denied the location you could also show an info message with "you have denied location service in the past for this site, do enable it do bla bla bla". and fill in the bla bla bla with whatever.

    0 讨论(0)
提交回复
热议问题