WorkerGlobalScope: online event
Note: This feature is only available in Web Workers.
The online
event of the WorkerGlobalScope
fires when the device reconnects to the internet.
Syntax
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
.
Example
The following code snippet shows an onoffline
handler set inside a worker:
js
self.ononline = () => {
console.log("Your worker is now online");
};
The same snippet, but using addEventListener()
:
js
self.addEventListener("online", () => {
console.log("Your worker is now online");
});
Specifications
Specification |
---|
HTML # handler-workerglobalscope-ononline |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
online event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
The WorkerGlobalScope
interface it belongs to.