The onoffline property of the WorkerGlobalScope interface represents an EventHandler to be called when the offline event occurs and bubbles through the Worker.


self.onoffline = function() { ... };


The following code snippet shows an onoffline handler set inside a worker:

self.onoffline = function() {
  console.log('Your worker is now offline');


Specification Status Comment
HTML Living Standard
The definition of 'WorkerGlobalScope.onoffline' in that specification.
Living Standard  

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onofflineChrome Full support 4Edge Full support ≤79Firefox Full support 29IE No support NoOpera ? Safari ? WebView Android Full support YesChrome Android Full support 40Firefox Android Full support 29Opera Android ? Safari iOS ? Samsung Internet Android Full support 4.0


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

The WorkerGlobalScope interface it belongs to.