if (navigator.onLine) { console.log("You are now connected to the network."); } else { console.log("The network connection has been lost."); }