navigator.geolocation.getCurrentPosition not allowed on “file:///C:/” based access [duplicate]

拜拜、爱过 提交于 2019-12-19 18:30:02

问题


Possible Duplicate:
HTML 5 Geo Location Prompt in Chrome

I've been looking at geolocation in Html 5. I'm using Chrome (12) and am accessing the html file using a path like this: file:///C:/_Development/Examples/Html5/boilerplate.html

I'm getting the little geolocation icon in the search bar that says that the location has been blocked from tracking your location.

Note that I don't have any exceptions setup at all...

Can this be done or do I need to host the file on a web server? If it can't be done, why can't it be done?

Thanks


回答1:


This is a duplicate of this question:

HTML 5 Geo Location Prompt in Chrome

It seems that chrome has security restrictions on accessing geolocation data locally. You need to host the file to use the data. A workaround with python is available in the previous question.



来源:https://stackoverflow.com/questions/6325796/navigator-geolocation-getcurrentposition-not-allowed-on-file-c-based-acce

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