You are here: Reference > JavaScript > client-side > event handling > events > ononline

ononline event | online event

Browser support:
Occurs when the browser starts to work online.
Note: The ononline event is supported in Internet Explorer from version 8 and in Firefox from version 3.
You can switch between working online and offline with the Work Offline menu item under the File menu in Internet Explorer and Firefox.
The ononline event only occurs if the browser is working offline and it starts to work online. The ononline event does not fire during the page load regardless that the browser is working online.

You can get whether the browser is working online or offline with the onLine property. If you need to detect when the browser starts to work offline, use the onoffline event.

How to register:

<ELEMENT ononline="handler">

In JavaScript:
object.ononline = handler;
object.addEventListener ("online", handler, useCapture);
object.attachEvent ("ononline", handler);
You can find the related objects in the Supported by objects section below.
The event object is accessible to all event handlers in all browsers. The properties of the event object contain additional information about the current event. To get further details about these properties and the possible event handler registration methods, please see the page for the event object.
For a complete list of events, see the page for Events in JavaScript.

Basic information:

Bubbles No
Cancelable No
Event object Event

Actions that invoke the ononline event:

  • Setting the browser to work online with the Work Offline menu item under the File menu.

Example HTML code 1:

This example illustrates the use of the ononline and onoffline events and the onLine property:
    <script type="text/javascript">
        function OnLoad () {
            if ('onLine' in navigator) {
                if (navigator.onLine) {
                    alert ("Your browser is working online.");
                else {
                    alert ("Your browser is working offline.");
            else {
                alert ("Your browser does not support the onLine property.");

        function OnOnline () {
            alert ("Your browser starts to work online.");
        function OnOffline () {
            alert ("Your browser starts to work offline.");
<body onload="OnLoad ()" ononline="OnOnline ();" onoffline="OnOffline ();" >
    Please click on the Work Offline menu item under the File menu to switch between working online and offline.
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content