Anjali Patel Anjali Patel - 1 month ago 11
HTML Question

How to check network connectivity in background using Javascript(HTML) for mobile devices?

I am creating a Hybrid mobile application and just want to check network connectivity so that to sync data online. I am recommended NOT to use JQuery/JQuery Mobile.
Any help would be appreciated.

Answer

You could use the events in javascript like this for online and offline . document.addEventListener("offline", yourCallbackFunction, false); document.addEventListener("online", yourCallbackFunction, false);

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

 function onOnline{
  //Handle the online event
 }