Android的2.3和PhoneGap的,navigator.online不起作用 [英] Android 2.3 and Phonegap, navigator.online does not work

查看:357
本文介绍了Android的2.3和PhoneGap的,navigator.online不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试navigator.online和它的工作,直到我构建应用程序与PhoneGap的,在这之后,navigator.online总是返回真。 有谁知道我非高速缓存或如何能刷新这个值?我需要它的点击事件。

I tested navigator.online and it worked until I built the app with PhoneGap, after that, navigator.online always returned true. Does anybody know how can I un-cache or refresh this value? I need it on "on click" events.

推荐答案

我也面临这个问题,而我是开发一个应用程序。

I was also facing this issue while I was developing an application.

我用的是:

document.addEventListener("online", onOnline, false);
document.addEventListener("offline", onOffline, false);

当器件断开或连接到互联网上飞这些事件将被解雇。

These events will be fired when the device is disconnected or connected to internet on the fly.

您可以存储在函数一些全局变量

You can store some global variables in the function

function onOnline(){}

function onOffline(){}

比检查这些全局变量的值,做任何你想要根据该值。

Than check the values of those global variables and do whatever you want to according to the value.

这篇关于Android的2.3和PhoneGap的,navigator.online不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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