html5 - http是否不支持h5 Geolocatio
本文介绍了html5 - http是否不支持h5 Geolocatio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
用本机ip访问无法获取坐标,用localhost访问倒是可以,有人遇到过吗
换成https也可以,但是就是http的不行
报错:
getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
解决方案
从chrome 50开始就不支持http的方式访问了, 需要切换成https
你本机搭的服务器 localhost 本身就被认为是安全的,类同https, 所以本地服务器跑是能够用来测试的
如果一定要用的话 可以设置这样看看
1、修改安全策略 --unsafely-treat-insecure-origin-as-secure="http://example.com" flag (假设"example.com" 就是你要跑的域名),
--user-data-dir=C:\testprofile
这篇关于html5 - http是否不支持h5 Geolocatio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文