javascript - 记住智能手机当前位置的选择

标签 javascript html google-chrome geolocation gps

我想根据智能手机的 GPS 坐标记录用户位置。

很简单,使用一个网站。我目前有这个工作,但有点烦人的是,当用户访问信息时,他们会被警报所困扰(是否可以使用你的位置)。我希望有一种方法可以让用户选择记住这个决定。尽管对这种能力没有信心。

欢迎提出任何想法或解决方案!

最佳答案

没有。你没有办法做到这一点。地理定位权限由浏览器本身处理。

来自geolocation API :

4.1 Privacy considerations for implementers of the Geolocation API

User agents must not send location information to Web sites without the express permission of the user. User agents must acquire permission through a user interface, unless they have prearranged trust relationships with users, as described below. The user interface must include the host component of the document's URI. Those permissions that are acquired through the user interface and that are preserved beyond the current browsing session (i.e. beyond the time when the browsing context is navigated to another URL) must be revocable and user agents must respect revoked permissions.

Some user agents will have prearranged trust relationships that do not require such user interfaces. For example, while a Web browser will present a user interface when a Web site performs a geolocation request, a VOIP telephone may not present any user interface when using location information to perform an E911 function.

获取权限并记住这些权限是用户代理的工作。

关于javascript - 记住智能手机当前位置的选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17356377/

相关文章:

javascript - HTML 注入(inject)时使用 CDN 或外部域的内联脚本后执行脚本文件

javascript - 带有简单数组的基本 ng-repeat

javascript - 我的光滑 slider 旋转木马有一个额外的白色幻灯片。有什么办法可以摆脱它?

html - 在绝对定位的 div 内垂直和水平对齐 anchor

javascript - 单击单选按钮时,显示/隐藏具有动态变化的 ID 或类的 div

javascript - 代码可以在 JS Fiddle 上运行,但不能在 Chrome 或 Firefox 中运行

javascript - Chrome 开发者工具中缺少文件夹

javascript - 如何在angularjs中将字符串时间转换为日期时间

javascript - 复选框树实现 - 获取选中的复选框

javascript - Chrome 扩展的多个上下文菜单条目?