window.addEventListener('load', function() { function updateOnlineStatus(event) { var condition = navigator.onLine ? "online" : "offline"; alert(condition); } window.addEventListener('online', updateOnlineStatus); window.addEventListener('offline', updateOnlineStatus); });
143200cookie-checkHTML API Online / Offline events (Javascript)