HTML5离线模式和地理位置 [英] HTML5 offline mode and geolocation

查看:105
本文介绍了HTML5离线模式和地理位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML5中处于离线模式时,仍有可能使用地理位置功能吗?看起来,当我在线(navigator.onLine = true)时,地理定位工作正常。但是当我离线时(navigator.onLine = false),我得到了我的错误回调,并且错误表明地理定位不可用。

Is it possible to still use the geolocation features when you are in offline mode in HTML5? It appears that when I am online (navigator.onLine = true), the geolocation works fine. But when I go offline (navigator.onLine = false), I get thrown to my error callback and the error indicates geolocation not available.

推荐答案

这取决于该特定浏览器中的GeoLocation如何连接。在Firefox中,GeoLocation取决于 Google定位服务通过向网络服务发送一些网络信息起作用 - 显然这在您离线时无法使用,因为网络服务不可用。

It's going to depend on how the GeoLocation in that particular browser is wired up. In Firefox, GeoLocation depends on Google Location Services which works by sending some network information to a web service - obviously this is not going to work when you're offline as the web service will not be available.

如果您有一个直接与GPS硬件进行通信的浏览器,那么它将脱机工作,但我认为您不会发现任何具有此类集成的桌面浏览器 - 可能是一些移动设备会的。

If you had a browser which communicated directly with GPS hardware then it would work offline, but I don't think you'll find any desktop browsers with that sort of integration - maybe some mobile ones will.

这篇关于HTML5离线模式和地理位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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