Onoffline event

Onoffline event The event object

Perform JavaScript while your browser is away from online:

<body onoffline="myFunction()">

Try it out . . .


Definitions and usages

The onoffline event is triggered when the browser is working offline.

Tip: The opposite of the onoffline event is ononline.

Tip: You can also use navigator.onLine property to wipe whether your browser is online or offline.


Browser support

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

Event
onoffline Not supported IE11 is obsolete
8.0
3.0 Not supported Not supported


Grammar

In HTML:

< element onoffline=" myScript "> Give it a try

In JavaScript:

object .onoffline=function(){ myScript }; Give it a try

In JavaScript, use the addEventListener() method:

object .addEventListener("offline", myScript ); Give it a try

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions of IE.


Technical details
Whether to support bubbling: No
Can I cancel: No
Types of events: Event
Supported HTML tags: <body>


Onoffline event The event object