WorkerGlobalScope: offline event
The offline
event of the WorkerGlobalScope
fires when the device loses connection to the internet.
Syntax
Use the event name in methods like addEventListener()
, or set an event handler property.
addEventListener('offline', event => { });
onoffline = event => { };
Event type
A generic Event
.
Example
The following code snippet shows an onoffline
handler set inside a worker:
self.onoffline = function() {
console.log('Your worker is now offline');
}
The same snippet, but using addEventListener()
:
self.addEventListener('offline', function() {
console.log('Your worker is now offline');
}
Specifications
No specification found
No specification data found for api.WorkerGlobalScope.offline_event
.
Check for problems with this page or contribute a missing spec_url
to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.
Browser compatibility
No compatibility data found for api.WorkerGlobalScope.offline_event
.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.
See also
The WorkerGlobalScope
interface it belongs to.