简体   繁体   English

移动HTML 5:检测互联网连接可用性

[英]Mobile HTML 5: Detect internet connection availability

Just that, is there a way to detect if the internet connection is available on a mobile device?. 仅仅是这样,有没有一种方法可以检测移动设备上是否可以连接互联网? Can I do some kind of ping to server using websockets? 我可以使用websocket对服务器执行ping操作吗? Will websockets help me with that? websockets可以帮助我吗?

I'm kinda desperate, because I thought websockets had a ping function on the client-side box, but not I try to find something about that, and there's nothing like that, besides websockets seem only to respond to connections and data transmission events. 我有点绝望,因为我认为websockets在客户端盒上具有ping功能,但是我没有尝试找到有关此功能的东西,除了websocket似乎只响应连接和数据传输事件外,没有其他东西。

You can try to ping a server, as you already considered. 您已经尝试过,可以尝试ping服务器。 This question contains a working example which uses the native Image object to do this. 这个问题包含一个使用本地Image对象执行此操作的示例。

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM