Detecting Internet Connection Using JavaScript

I am currently creating a Cached iPhone application with some features that require the Internet and other features that do not. I would like to know how to detect an Internet connection with JavaScript so that the text “No Internet connection” is displayed on certain pages, and others as usual.

+3
source share
2 answers

In HTML5 you can use:

 navigator.onLine

to detect your internet connection.

LIVE DEMO: http://jsfiddle.net/DerekL/fHQK4/

+9
source

You can make iframe and install src in google. If it does not start the download in seconds, they probably do not have internet.

0

All Articles