NetworkInformation.ontypechange

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The NetworkInformation.ontypechange event handler is a property containing the code to execute when the typechange event, of type Event, is received by this NetworkInformation instance. That event is sent by the browser to let content know that the value of the NetworkInformation.type attribute has changed.

This was present in early versions of the specification and has been replaced by the NetworkInformation.onchange event handler. Implementations have not yet all switched to the new standard event.

Syntax

networkinformation.ontypechange = function;

Values

  • function is the name of a user-defined function, without the () suffix or any parameters, or an anonymous function declaration, such as function(event) {...}.  An event handler always has a single parameter: an event object, of type Event in this case.

Example

// Get the connection type.
var type = navigator.connection.type;

function changeHandler(e) {
  // Handle change of connection type here.
}

// Register for event changes:
navigator.connection.ontypechange = changeHandler;

// Another way:
navigator.connection.addEventListener('typechange', changeHandler);

Specifications

Although present in some drafts, this is not part of any standard.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support Not supported 31 (31) Not supported Not supported Not supported
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Firefox OS
Basic support Not supported 38 31.0 (31) ? ? ? 2.0

See also

Document Tags and Contributors

 Contributors to this page: teoli, Jeremie, fscholz, gskachkov, Sheppy, Biraj
 Last updated by: teoli,