navigator.userAgent

ユーザーエージェント名を返します。ブラウザの判別を行うにはuserAgentプロパティを使って調べます。ただし、userAgentの文字列も自由に設定できるブラウザがあるため正確な判別を行うには限界があります。なお、Operaの場合はwindow.operaプロパティを調べることにより判別することができます。

構文

navigator.userAgent

例文

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

関連記事

スポンサーリンク

Built-In Variables 組み込み変数

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

上に戻る