admin管理员组

文章数量:1291616

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() 
}

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() 
}
Share Improve this question edited Jul 8, 2014 at 14:07 FelipeAls 22.2k9 gold badges56 silver badges74 bronze badges asked Sep 15, 2008 at 20:15 TedTed 512 silver badges4 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

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

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

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/show_bug.cgi?id=19105

本文标签: javascriptChecking online status from an iPhone web appStack Overflow