请HTML5地理位置请求允许每次用户重新加载页面 [英] Make html5 geolocation ask permission every time user reloads the page

查看:148
本文介绍了请HTML5地理位置请求允许每次用户重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们需要:

我们已经在我们的网站上的一些网页,其中允许用户输入一些数据,并搜索其他用户在他们的区域。当用户打开该页面必须显示弹出信息

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 想用您的当前位置。

之后,用户可以丢弃和手工填写位置字段或接受并自动重定向到搜索结果页。

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

问题:

问题是,当用户选择的在第一时间提到的选项,浏览器能记住它,不问它下一次。因此,当用户接受它,每次他打开搜索网页时它会自动重定向他到搜索结果页withous要求任何东西。

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:

我们正在使用基本的HTML5地理位置code

We are using basic html5 geolocation code

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

结论:

我是pretty确保它不可能改变是浏览器的原生许可。但我希望有人能给这个问题很好的解决方案。谢谢你。

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.

推荐答案

一旦用户点击拒绝/让浏览器记住该网站这一决定。

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

要避免否认最好的办法是只调用getCurrentPosition(...),当用户点击的东西,这意味着他要用他的位置。然后他可能会很乐意分享:)

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 :)

一个很好的例子是在Foursquare上的网站。在进入它提供你通过点击我的位置,它会提示它在地图上的按钮即可进入地图的一些城市,只有在那里。

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.

这篇关于请HTML5地理位置请求允许每次用户重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆