Learn how to detect whether the browser is online or offline with JavaScript.
Offline Detection
The onLine property of the Navigator object returns a Boolean value that specifies whether the browser is in online or offline mode:
Example
Find out whether the browser is online:
js
var x = "Is the browser online? " + navigator.onLine;
Read more about the Navigator Object in the JavaScript Navigator Tutorial.