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.


networkinformation.ontypechange = function;


  • 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.


// 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);


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


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API Event Handler Network Information API Non-standard Property Reference