最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Make html5 geolocation ask permission every time user reloads the page - Stack Overflow

programmeradmin1浏览0评论

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 that page the popup message must be shown

would like to use your current location.

After that user can discard that and fill the location fields manually or accept and be automatically redirected to results page.

Problem:

The problem is that when user selects any of the mentioned options at first time, browser remembers it and don't ask it next time. So when user accept it, every time he open the search page it will automatically redirect him to results page withous asking anything.

Code:

We are using basic html5 geolocation code

if (navigator.geolocation) {
   navigator.geolocation.getCurrentPosition(LocationMethod);
} 

Conclusion:

I'm pretty sure that it's impossible to change permission that are browser-native. But I hope that someone will give nice solution for this problem. Thanks.

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 that page the popup message must be shown

http://foo.bar.com would like to use your current location.

After that user can discard that and fill the location fields manually or accept and be automatically redirected to results page.

Problem:

The problem is that when user selects any of the mentioned options at first time, browser remembers it and don't ask it next time. So when user accept it, every time he open the search page it will automatically redirect him to results page withous asking anything.

Code:

We are using basic html5 geolocation code

if (navigator.geolocation) {
   navigator.geolocation.getCurrentPosition(LocationMethod);
} 

Conclusion:

I'm pretty sure that it's impossible to change permission that are browser-native. But I hope that someone will give nice solution for this problem. Thanks.

Share Improve this question edited May 3, 2013 at 18:48 Chuck Norris asked May 3, 2013 at 7:42 Chuck NorrisChuck Norris 15.2k15 gold badges95 silver badges127 bronze badges 2
  • “I'm pretty sure that it's impossible to change permission that are browser-native.” – correct. If the user decides on first display of that message, that he never wants to be asked by that page again – then that’s how it is. Nothing you can do about it. – C3roe Commented May 3, 2013 at 8:10
  • Have you found solution? – zt50tz Commented Apr 7, 2015 at 10:51
Add a comment  | 

1 Answer 1

Reset to default 15

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)

  1. 暂无评论