SYNCERのロゴ
アイキャッチ画像

NetworkInformation - ネットワーク情報

NetworkInformationは、デバイスのネットワーク情報を管理するための機能を備えたインターフェイスです。

概要

名前
NetworkInformation
IDL
[Exposed=(Window,Worker)]
interface NetworkInformation : EventTarget {
  readonly attribute ConnectionType type;
  readonly attribute EffectiveConnectionType effectiveType;
  readonly attribute Megabit downlinkMax;
  readonly attribute Megabit downlink;
  readonly attribute Millisecond rtt;
  readonly attribute boolean saveData;
  attribute EventHandler onchange;
};

enum ConnectionType {
    "bluetooth",
    "cellular",
    "ethernet",
    "mixed",
    "none",
    "other",
    "unknown",
    "wifi",
    "wimax"
};

enum EffectiveConnectionType {
    "2g",
    "3g",
    "4g",
    "slow-2g"
};

typedef unrestricted double Megabit;

typedef unsigned long long Millisecond;

typedef EventHandlerNonNull? EventHandler;

callback EventHandlerNonNull = any (Event event);
仕様書
https://wicg.github.io/netinfo/#dom-networkinformation

チュートリアル

NetworkInformationは、NavigatorNetworkInformation.connectionが返します。

window.navigator.connection ;
navigator.connection ;	// windowは省略可

コンストラクタ

コンストラクタはありません。

プロパティ

直近の回線の下り速度を返します。

downlinkMax

回線の下り速度の最大値を返します。

effectiveType

回線速度のレベル(ECT)を文字列で返します。

rtt

ラウンドトリップタイム(RTT)をミリ秒単位で返します。

saveData

ユーザーが、ユーザーエージェントの機能でデータ通信量を制限しているか否かを返します。

type

ネットワークが使用している技術を文字列で返します。

メソッド

固有のメソッドはありません。

定数

固有の定数はありません。

イベント

onchange

内部でネットワーク情報が更新された時に発火します。

サポート状況

クリックすると、バージョンごとの対応状況を確認できます。

FeaturesChromeFirefoxSafariEdgeIEOperaiOS SafariAndroid
NetworkInformation 61+×××× 48+××
downlink 61+×××× 48+××
downlinkMax××××××××
effectiveType 61+×××× 48+××
onchange 61+×××× 48+××
rtt 61+×××× 48+××
saveData××××××××
type××××××××
  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2017年10月15日 (日)
コンテンツを公開しました。