Rascals are always sociable, and the chief sign that a man has any nobility in his character is the little pleasure he takes in others company. Arthur Schopenhauer

Monitor network status with JavaScript

How to monitor network status with JavaScript

To check the network connection:

if (navigator.onLine) {
	alert('You are online');
} else {
	alert('You are offline');

And to detect changes in the network status (when the computer goes online or offline):

window.addEventListener('online', () => alert('You are online'));
window.addEventListener('offline', () => alert('You are offline'));