This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.


Overview Table

Synchronous No
Bubbles No
Target dom/Element
Cancelable No
Default action
## Examples

The following example sets an event handler that responds to both ononline and onoffline events using the type property of the event object.

function reportConnectionEvent(e)
    if (!e) e = window.event;

    if ('online' == e.type) {
        alert( 'The browser is ONLINE.' );
    else if ('offline' == e.type) {
        alert( 'The browser is OFFLINE.' );
    else {
        alert( 'Unexpected event: ' + e.type );
window.onload = function() {
    document.body.ononline = reportConnectionEvent;
    document.body.onoffline = reportConnectionEvent;



If Asynchronous JavaScript and XML (AJAX) Connection Services are disabled, this event is not raised. (These services are enabled by default.) To invoke this event, do one of the following:

  • Set the browser to “Work Offline” on the File menu.


Standards information

There are no standards that apply here.

Event handler parameters

pEvtObj [in]
Type: ****IHTMLEventObj****

See also

Related pages