Javascript: Is my browser on line?

PHOTO EMBED

Sun Aug 28 2022 12:30:38 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #javascript

if (navigator.onLine){
  alert('You r connected!');
} else {
  alert('No connection :(');
}
content_copyCOPY

Single way to know if our browser is on line (internet connection). This top was taken from blogs. Non tested for all browsers. I will test it when I can but I was interested on this.