navigator.onLine

オンライン作業中かオフライン作業中かを返します。trueであればオンライン、falseであればオフラインとなります。ただし、この結果はInternet Explorerのファイルメニュー内のオフライン作業の項目にチェックが入っているかどうかを示すものになります。つまり、実際にネットワークに接続されているかどうかを調べることはできません。 このプロパティはWindows版Internet Explorer 4以降、Macintosh版Internet Explorer 5、iCab 3以降で利用できます。

構文

navigator.onLine

例文

<html>
 <head>
  <title>navigator.onLine</title>
  <script type="text/javascript"><!--
  window.onload = function() {
   var flag = navigator.onLine;
   document.getElementById("result").innerHTML = flag;
  }
  // --></script>
 </head>
 <body>
 <div id="result"></div>
 </body>
</html>

関連記事

スポンサーリンク

ブロックのIDと場所

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る