Checking online status from an iPhone web app

对着背影说爱祢 提交于 2019-12-09 00:09:44

问题


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:


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




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/66492/checking-online-status-from-an-iphone-web-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!