Navigator 浏览器对象,包含了正在使用的 Navigator 的版本信息。反映了当前使用的浏览器的资料。JavaScript 客户端运行时刻引擎自动创建 navigator 对象。
更详细的信息可以去查msdn或者Navigator 2.0以后的说明文档,这里我们之做个简单的说明
包括一下几大属性:

  • appCodeName 返回浏览器的“码名”(?),流行的 IE 和 NN 都返回 'Mozilla'。
    下面的例子显示了 appCodeName 属性的值:
    document.write("navigator.appCodeName 的值是" + navigator.appCodeName)
  • appName 返回浏览器名。IE 返回 'Microsoft Internet Explorer',NN 返回 'Netscape'。
    下面的例子显示了 appName 属性的值:
    document.write("navigator.appName 的值是 " + navigator.appName)
  • appVersion 返回浏览器版本,包括了大版本号、小版本号、语言、操作平台等信息。
  • language 语言
  • mimeType 以数组表示所支持的MIME类型
  • platform 返回浏览器的操作平台,对于 Windows 9x 上的浏览器,返回 'Win32'(大小写可能有差异)。
  • userAgent 返回以上全部信息。例如,IE5.01 返回 'Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)'。
  • plugins 以数组表示已安装的外挂程序
  • javaEnabled() 返回一个布尔值,代表当前浏览器允许不允许 Java。

检测浏览器的版本、所支持的MIME类型、已安装的外挂程序(plug-in)。该对象包含两个子对象:外挂对象、MIME类型对象。
例如:

<Script>
with (document) {
     write (
"你的浏览器信息:<OL>");
     write (
"<LI>代码:"+navigator.appCodeName);
     write (
"<LI>名称:"+navigator.appName);
     write (
"<LI>版本:"+navigator.appVersion);
     write (
"<LI>语言:"+navigator.language);
     write (
"<LI>编译平台:"+navigator.platform);
     write (
"<LI>用户表头:"+navigator.userAgent);
}

</Script>


例如:

<Script>
if (document.all) {
    document.write(
"你的浏览器是:MSIE");
}
    else {
    document.write(
"你的浏览器是:Navigator");
}

</Script> 

Screen
基本JavaScript的Screen屏幕对象

  • screen 屏幕对象 反映了当前用户的屏幕设置。
  • width 返回屏幕的宽度(像素数)。
  • height 返回屏幕的高度。
  • availWidth 返回屏幕的可用宽度(除去了一些不自动隐藏的类似任务栏的东西所占用的宽度)。
  • availHeight 返回屏幕的可用高度。
  • colorDepth 返回当前颜色设置所用的位数 - 1:黑白;8:256色;16:增强色;24/32:真彩色


    下面是英文的Navigator浏览器的屏幕对象:

  • availHeight:minus permanent or semipermanent user interface features displayed by the operating system:such as the Taskbar on Windows.  
  • availWidth:Specifies the width of the screen, in pixels, minus permanent or semipermanent user interface:features displayed by the operating system, such as the Taskbar on Windows.  
  • colorDepth:The bit depth of the color palette, if one is in use; otherwise, the value is derived from screen.pixelDepth.  
  • height:Display screen height.  
  • pixelDepth:Display screen color resolution (bits per pixel).  
  • width:Display screen width.

History
JavaScript中的History历史对象包含了用户已浏览的 URL 的信息,是指历史对象指浏览器的浏览历史。鉴于安全性的需要,该对象收到很多限制,现在只剩下下列属性和方法。History历史对象有length这个属性,列出历史的项数。JavaScript 所能管到的历史被限制在用浏览器的“前进”“后退”键可以去到的范围。本属性返回的是“前进”和“后退”两个按键之下包含的地址数的和。

History历史对象并有以下方法

  • back() 后退,跟按下“后退”键是等效的。
  • forward() 前进,跟按下“前进”键是等效的。
  • go() 用法:history.go(x);在历史的范围内去到指定的一个地址。如果 x < 0,则后退 x 个地址,如果 x > 0,则前进 x 个地址,如果 x == 0,则刷新现在打开的网页。history.go(0) 跟 location.reload() 是等效的。


posted on 2007-12-03 18:43 湘江夜游神 阅读(486) 评论(0)  编辑  收藏 所属分类: JavaScript

只有注册用户登录后才能发表评论。


网站导航:
 

Locations of visitors to this page