简体   繁体   中英

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? Will websockets help me with that?

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.

You can try to ping a server, as you already considered. This question contains a working example which uses the native Image object to do this.

I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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