Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите закончить эту работу!
Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The NetworkInformation.ontypechange
event handler is a property containing the code to execute when the typechange
event, of type Event
, is received by this NetworkInformation
instance. That event is sent by the browser to let content know that the value of the NetworkInformation.type
attribute has changed.
This was present in early versions of the specification and has been replaced by the NetworkInformation.onchange
event handler. Implementations have not yet all switched to the new standard event.
Syntax
networkinformation.ontypechange = function;
Values
function
is the name of a user-defined function, without the()
suffix or any parameters, or an anonymous function declaration, such asfunction(event) {...}
. An event handler always has a single parameter: an event object, of typeEvent
in this case.
Example
// Get the connection type. var type = navigator.connection.type; function changeHandler(e) { // Handle change of connection type here. } // Register for event changes: navigator.connection.ontypechange = changeHandler; // Another way: navigator.connection.addEventListener('typechange', changeHandler);
Specifications
Although present in some drafts, this is not part of any standard.
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | Not supported | 31 (31) | Not supported | Not supported | Not supported |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Firefox OS |
---|---|---|---|---|---|---|---|
Basic support | Not supported | 38 | 31.0 (31) | ? | ? | ? | 2.0 |
See also
- The
typechange
event and its type,Event
. NetworkInformation.onchange
, its standard counterpart.