MDN self-hosted library · e01.org

Window: online event

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
// addEventListener version
window.addEventListener("online", (event) => {
  console.log("You are now connected to the network.");
});

// ononline version (but note that this replaces other event listeners
// added using ononline, if any)
window.ononline = (event) => {
  console.log("You are now connected to the network.");
};