How to check if online/offline

Learn how to use JavaScript to detect whether the browser is online or offline.

Offline Detection

navigator of the onLine The property returns a boolean value to determine whether the browser is in online mode or offline mode:

Example

Check if the browser is online:

var x = "Is the browser online? " + navigator.onLine;

Try It Yourself