<p>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.</p>

<p>In Firefox/regular WebKit, this would be:</p>

<pre><code>if(navigator.onLine) 
{
    onlineCode() 
}
</code></pre>

[{'answer_id': 66521, 'author': 'Loren Segal', 'author_id': 6436, 'author_profile': 'https://Stackoverflow.com/users/6436', 'pm_score': 2, 'selected': False, 'text': '<p>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.</p>\n\n<p><a href="https://bugs.webkit.org/show_bug.cgi?id=19105" rel="nofollow noreferrer">https://bugs.webkit.org/show_bug.cgi?id=19105</a></p>\n'}, {'answer_id': 426691, 'author': 'Isaac Waller', 'author_id': 764272, 'author_profile': 'https://Stackoverflow.com/users/764272', 'pm_score': 2, 'selected': False, 'text': '<p>img src="http://aonlinesite.com/a-really-little-image.png" onload="Intenet!" onerror="NoInternet!" </p>\n'}, {'answer_id': 725378, 'author': 'pr1001', 'author_id': 46768, 'author_profile': 'https://Stackoverflow.com/users/46768', 'pm_score': 2, 'selected': False, 'text': '<p>A quick test on the iPhone shows that it is available from iPhone OS 2.2.</p>\n'}]
['https://Stackoverflow.com/questions/66492', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6842/']