Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

onoffline event

onoffline event

Event Object Reference Event Object

Example

Execute JavaScript when the browser works offline:

Try it »


Definition and Usage

The onoffline event is triggered when the browser works offline.

Tip: The opposite event of onoffline is ononline .

Tip: You can also use navigator.onLine the property to check whether the browser is in online or offline mode.


Browser support

The numbers in the table indicate the version number of the first browser to support the event.

Events
onoffline Not supported IE11 deprecated
8.0 3.0 Not supported Not supported

Syntax

In HTML:

<

element

onoffline="

myScript

">

Try it

In JavaScript:

object

.onoffline=function(){

myScript

};

Try it

In JavaScript, use the addEventListener() method:

object

.addEventListener("offline",

myScript

);

Try it

Note: Internet Explorer 8 and earlier IE versions do not support addEventListener() method.


Technical Details

Does it support bubbling: No
Is it cancelable: No
Event type: Event
Supported HTML tags:

Event Object Reference Event Object