This document is an Editor's draft and should be treated only as such, and is subject to consensus of the DAP WG.
This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.
Implementations that use ECMAScript to implement the APIs defined in this specification must implement them in a manner consistent with the ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], as this specification uses that specification and terminology.
The Network Information API provides an interface for Web Applications to access the underlying netowrk information (e.g. connection info) of the device.
The devices today are able to connect to multiple networks (e.g. Cellular, WiFi), and this API enables the Web Applications to get accesss to such information i.e. the type of network, so it may present it to the User for information and/or adapt its content to reflect the underlying network connectivity.
var connection, connectionSpeed, htmlNode, htmlClass; // create a custom object if navigator.connection isn't available connection = navigator.connection || {'type':'0'}; // set connectionSpeed switch(connection.type) { case connection.CELL_3G: // 3G connectionSpeed = 'mediumbandwidth'; break; case connection.CELL_2G: // 2G connectionSpeed = 'lowbandwidth'; break; case connection.NONE: //N connectionSpeed = 'no-connectivity'; default: // WIFI, ETHERNET, UNKNOWN, CELL_4G connectionSpeed = 'highbandwidth'; } // set the connection speed on the html element's class attribute htmlNode = document.body.parentNode; htmlClass = htmlNode.getAttribute('class') || ''; htmlNode.setAttribute('class', htmlClass + ' ' + connectionSpeed);
This section is under development.
The NetworkInfo
interface is exposed on the Navigator
interface.
The Connection interface provides a handle to connection information such as connection type, and roaming information.
TBD
The editors would like to thank the input from W3C DAP members to date ...