Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

NetworkInformation.ontypechange

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

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 as function(event) {...}.  An event handler always has a single parameter: an event object, of type Event 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

ドキュメントのタグと貢献者

 このページの貢献者: teoli, Jeremie, fscholz, gskachkov, Sheppy, Biraj
 最終更新者: teoli,