当前位置: 首页 > 文档资料 > MooTools 中文文档 >

Browser

优质
小牛编辑
115浏览
2023-12-01

Object: Browser

包含浏览器各种属性的对象。

Browser.Features

  • Browser.Features.xpath - (boolean) True如果浏览器支持XPath 。
  • Browser.Features.air - (boolean) True如果浏览器支持AIR 。
  • Browser.Features.query - (boolean) True如果浏览器支持querySelectorAll 。
  • Browser.Features.json - (boolean) True如果浏览器有一个原生的JSON对象。
  • Browser.Features.xhr - (boolean) True如果浏览器支持原生XMLHTTP对象。

Browser.name

"Browser.name"浏览器名,也可使用以下形式表示:

  • Browser.ie - (boolean) True如果当前浏览器是IE。
  • Browser.firefox - (boolean) True如果当前浏览器是Firefox 。
  • Browser.safari - (boolean) True如果当前浏览器是Safari。
  • Browser.chrome - (boolean) True如果当前浏览器是Chrome。
  • Browser.opera - (boolean) True如果当前的浏览器是Opera。

除了上述的特性,还可以包含浏览器的主要版本号('Browser.ie6','Browser.chrome15',...)。

如果'Browser.chrome'是真,其他所有可能的属性,如"Browser.firefox','Browser.ie' , ...将是underfined。

例如:

alert(Browser.name); // Alerts "ie" in Internet Explorer, "firefox" in Mozilla Firefox, "chrome" in Google Chrome, "safari" or "opera".
 
if (Browser.ie){
    // This code will only run in IE
}
 
if (Browser.firefox2){
    // This code will only run in Firefox 2
}
 
if (Browser.ie6 || Browser.ie7){
    // Please upgrade your browser
}

如果IE浏览器文档使用X-UA-Compatible向后兼容模式的报头,Browser对象被视为浏览器的早期版本上运行。

Browser.version

"Browser.version"浏览器的版本号。

例如:

alert(Browser.version); // Alerts '3.6' in FireFox 3.6.13

Browser.Platform

  • Browser.Platform.mac - (boolean) True如果平台是Mac上。
  • Browser.Platform.win - (boolean) True如果平台是Windows 。
  • Browser.Platform.linux - (boolean) True如果平台是Linux 。
  • Browser.Platform.ios - (boolean) True如果平台是iOS。
  • Browser.Platform.android - (boolean) True如果平台是Android
  • Browser.Platform.webos - (boolean) True如果平台的WebOS
  • Browser.Platform.other - (boolean) True如果平台既不是以上OS。
  • Browser.Platform.name - (string)平台的名称。

Browser.Plugins

  • Browser.Plugins.Flash - (object) Flash插件对象。注:如果未安装Flash,Browser.Plugins.Flash.version和Browser.Plugins.Flash.build将返回0。
  • Browser.Plugins.Flash.version - (number)安装flash插件的主版本号。
  • Browser.Plugins.Flash.build - (number) 安装flash插件的内部版本号。

Browser.Request

  • Browser.Request - (object)XMLHTTP对象。

Browser.exec

执行传入的字符串,类似于浏览器原生函数eval。

例如:

Browser.exec('alert("Moo!");');