NetworkInformation: change event

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

The change event fires when connection information changes, and the change is received by the NetworkInformation object.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener('change', event => { });

onchange = event => { };

Event type

A generic Event.

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

No specification found

No specification data found for api.NetworkInformation.change_event.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility

No compatibility data found for api.NetworkInformation.change_event.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.