NetworkInformation: change event
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Note: This feature is available in Web 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.
js
addEventListener("change", (event) => {});
onchange = (event) => {};
Event type
A generic Event
.
Examples
js
// 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
Specification |
---|
Network Information API # dom-networkinformation-onchange |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
change event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.