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
|
Examples
// 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 | Status |
| HTML Living StandardThe definition of 'online event' in that specification. | Living Standard |
Browser compatibility
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
online event
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support Yes |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support Yes |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
See also
Window: online event by Mozilla Contributors is licensed under CC-BY-SA 2.5.