Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("online", (event) => {});
ononline = (event) => {};
Event type
A generic Event
.
Event handler aliases
In addition to the Window
interface, the event handler property ononline
is also available on the following targets:
Examples
js
/ addEventListener version
window.addEventListener("online", (event) => {
console.log("You are now connected to the network.");
});
/ ononline version
window.ononline = (event) => {
console.log("You are now connected to the network.");
};
Specifications
Specification |
---|
HTML # handler-window-ononline |
Browser compatibility
BCD tables only load in the browser