onoffline event (Internet Explorer)

Switch View :
ScriptFree
onoffline event

[This documentation is preliminary and is subject to change.]

Raised when Windows Internet Explorer is working offline.

This event is not supported for Metro style apps using JavaScript.

Internet Explorer 8

Syntax

HTML Attribute <element onoffline = "handler(event)">
Event Property object.onoffline = handler;
attachEvent Method object.attachEvent("onoffline", handler)
addEventListener Method object.addEventListener("offline", handler, useCapture)

Standards information

There are no standards that apply here.

Event information

SynchronousNo
BubblesNo
CancelableNo

Event handler parameters

pEvtObj [in]

Type: IHTMLEventObj

Remarks

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.

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;
}  

See also

body
frameSet
window
Reference
onLine
ononline

 

 

Build date: 3/14/2012

Community Content

bedney
As of IE8b2, also available on Windows XP
All -

As of IE8 beta2, this event is now available on Windows XP (as per my request :-) ). Thank you Microsoft!

Cheers,

- Bill