Firefox Tomorrow

web api event

NetworkInformation: change event

View on MDN ↗

Available in workers

The change event of the NetworkInformation interface fires when connection information changes, and the event 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.
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);

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.