views:

718

answers:

3

Is there a way to check to see if an iphone is online from a web app. That is, in mobile safari, can I check the online status of the device to see if I should try an ajax call or not.

In firefox/regular webkit, this would be

if(navigator.onLine) { onlineCode() }
+1  A: 

That same code should work in the WebKit nightly build as of May 16th 2008. I guess that means you need to hope the 2.1 update included a new build of safari.

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

Loren Segal
A: 

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

Isaac Waller
A: 

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

pr1001