Check online status from iPhone web application

Is there a way to check if the iPhone is on the Internet from a web application. That is, in mobile Safari, I can check the online status of the device to find out if I should try the AJAX call or not.

In Firefox / regular WebKit, this will be:

if(navigator.onLine) 
{
    onlineCode() 
}
+5
source share
3 answers

img src = "http://aonlinesite.com/a-really-little-image.png" onload = "Intenet!" OnError = "NoInternet!"

+4
source

A quick test on the iPhone shows that it is available with iPhone OS 2.2.

+3
source

The same code should work in the nightly build of WebKit from May 16, 2008. That probably means you need to hope that update 2.1 includes a new safari build.

https://bugs.webkit.org/show_bug.cgi?id=19105

+2
source

All Articles