How to check online/offline status

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

Offline detection

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

Example

Check if the browser is online:

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

Попробуйте сами