Window: online event

The online event of the Window interface is fired when the browser has gained access to the network and the value of Navigator.onLine switches to true.

Note: This event shouldn't be used to determine the availability of a particular website. Network problems or firewalls might still prevent the website from being reached.
Bubbles No
Cancelable No
Interface Event
Event handler property ononline


// 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.");


Specification Status
HTML Living Standard
The definition of 'online event' in that specification.
Living Standard

Browser compatibility

ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
online eventChrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes


Full support
Full support

See also