日期:2014-05-16  浏览次数:20322 次

js获取浏览器版本信息、屏幕分辩率
<html>
<head>
<title>JS完整获取IE浏览器信息</title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="435" border="1" cellspacing="3" cellpadding="0">
  <tr>
    <td>浏览器类型</td>
    <td>
      <script>document.write(navigator.appName)</script>
    </td>
  </tr>
  <tr>
    <td >浏览器版本</td>
    <td >
      <script>document.write(navigator.appVersion)</script>
    </td>
  </tr>
  <tr>
    <td>浏览器语言</td>
    <td>
      <script>document.write(navigator.browserLanguage)</script>
    </td>
  </tr>
  <tr>
    <td >CPU类型</td>
    <td >
      <script>document.write(navigator.cpuClass)</script>
    </td>
  </tr>
  <tr>
    <td>操作系统</td>
    <td>
      <script>document.write(navigator.platform)</script>
    </td>
  </tr>
  <tr>
    <td >系统语言</td>
    <td >
      <script>document.write(navigator.systemLanguage)</script>
    </td>
  </tr>
  <tr>
    <td>用户语言;</td>
    <td>
      <script>document.write(navigator.userLanguage)</script>
    </td>
  </tr>
  <tr>
    <td >在线情况</td>
    <td >
      <script>document.write(navigator.onLine)</script>
    </td>
  </tr>
  <tr>
    <td>屏幕分辨率</td>
    <td>      <script>document.write(window.screen.width+"x"+window.screen.height)</script></td>
  </tr>
  <tr>
    <td>颜色</td>
    <td> <script>document.write(window.screen.colorDepth+"位")</script></td>
  </tr>
  <tr>
    <td>字体平滑</td>
    <td><script>document.write(window.screen.fontSmoothingEnabled)</script></td>
  </tr>
  <tr>
    <td>appMinorVersion</td>
    <td>
      <script>document.write(navigator.appMinorVersion)</script>
    </td>
  </tr>
  <tr>
    <td >appCodeName</td>
    <td >
      <script>document.write(navigator.appCodeName)</script>
    </td>
  </tr>
  <tr>
    <td>cookieEnabled</td>
    <td>
      <script>document.write(navigator.cookieEnabled)</script>
    </td>
  </tr>
  <tr>
    <td >userAgent</td>
    <td >
      <script>document.write(navigator.userAgent)</script>
    </td>
  </tr>
  <tr>
    <td>javaEnabled</td>
    <td>
      <script>document.write(navigator.javaEnabled())</script>
    </td>
  </tr>
  <tr>
    <td >taintEnabled</td>
    <td >
      <script>document.write(navigator.taintEnabled())</script>
    </td>
  </tr>
</table>
</body>
<!--
 
上述代码可以放在浏览器里运行!
 
--------------------------------------------------------------------------------------------------
下面代码可获取准确浏览器版本号信息:
今天写了个js,由于IE6、IE7和IE8存在兼容问题,所以需要获取IE的版本号。下面的HTML可以输出浏览器的信息。可以作为调试或编码时的参考。
当然第一个html的代码可以用在firefox中用来获取浏览器信息。第二个js对firefox就没什么意义了。
<html>
    <body>
        <script language="Javascript">
        //输出浏览器信息
        document.write("浏览器名称:"+navigator.appName+"<br />");
        document.write("版本号:"+navigator.appVersion+"<br />");
        document.write("代码名字:"+navigator.appCodeName+"<br />");
        document.write("用户代理标识:"+navigator.userAgent);
        </script>
    </body>
</html> 
以下的js是获取IE浏览器的版本号。先要判断是否为IE(firefox不执行,version为undefine),然后提取版本号并返回Float型结果,如IE7返回7
<script language="Javascript">
 //区分浏览器信息编号
var  version=0;
if(navigator.appName.indexOf("Intern