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 event is received by the NetworkInformation object.


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

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

onchange = (event) => {};

Event type

A generic Event.


// Get the connection type.
const 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);


Network Information API
# dom-networkinformation-onchange

Browser compatibility

BCD tables only load in the browser