NetworkInformation.onchange

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The NetworkInformation.onchange event handler contains the code that is fired when connection information changes, and the change is received by the NetworkInformation object.

Syntax

netInfo.onchange = function() { ... }

Examples

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

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

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

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

Specifications

Specification Status Comment
Network Information API
The definition of 'onchange' in that specification.
Draft Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support61 ? No No48 No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support5038 ? No137 No ?

1. On Firefox, the event handler property corresponding to the change event is ontypechange.

Document Tags and Contributors

Contributors to this page: fscholz, jpmedley, chrisdavidmills, YuichiNukiyama, teoli
Last updated by: fscholz,