HTML5 Geolocation, ask for location?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 13:46:27

问题


Is it possible to ask for the user's permission to get their location on demand? It's usually asked when the page asks for the location, such as navigator.geolocation, but won't ask again until after the page has reloaded and the script asks for the location again.

Is there anyway to have it ask on demand, ex.) after the user hits deny?


回答1:


You have to either request location from another domain, or provide instructions on how to go into their browser and change their settings. Just like on iPhone how you have to go into settings if you accidentally deny a permission.

It's because the permission-asking is actually something implemented on a per-browser basis. You can imagine if geolocation was around in IE6 days, IE6 would automatically always accept. Your solution would have to execute based on the browser someone is using.



来源:https://stackoverflow.com/questions/12009501/html5-geolocation-ask-for-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!