Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
$(window).on("online offline", function() { const online = navigator.onLine; if (online) { $("#offline-banner").hide(); // Re-sync queued actions processOfflineQueue(); } else { $("#offline-banner").show().text("You are offline. Changes will sync when reconnected."); } }); // Check on load if (!navigator.onLine) $("#offline-banner").show(); // Queue actions for later sync const offlineQueue = []; function queueAction(action) { if (navigator.onLine) action(); else offlineQueue.push(action); }
Result
Open