Module: browser

本模块提供浏览器检测相关方法。
Source:

Methods

(static) ieVersion(uaopt) → {string}

获取指定 useragent 字符串中的 IE 浏览器版本号。
Parameters:
Name Type Attributes Description
ua string <optional>
useragent 字符串,浏览器环境下默认为 navigator.userAgent。
Author:
  • luoliquan
Source:
Returns:
IE 浏览器版本号,不符合该浏览器特征时返回空字符串。
Type
string

(static) iOSVersion(uaopt) → {string}

获取指定 useragent 字符串中的 iOS 版本号。
Parameters:
Name Type Attributes Description
ua string <optional>
useragent 字符串,浏览器环境下默认为 navigator.userAgent。
Since:
  • 1.6.0
Source:
Returns:
iOS 版本号,不符合该系统特征时返回空字符串。
Type
string

(static) isAndroid(uaopt) → {boolean}

检查指定 useragent 字符串是否符合安卓系统特征。
Parameters:
Name Type Attributes Description
ua string <optional>
useragent 字符串,浏览器环境下默认为 navigator.userAgent。
Author:
  • luoliquan
Source:
Returns:
是否符合安卓系统特征。
Type
boolean

(static) isHuawei(ua) → {boolean}

检查指定 useragent 字符串是否符合华为或荣耀设备特征。
Parameters:
Name Type Description
ua string useragent 字符串,浏览器环境下默认为 navigator.userAgent。
Since:
  • 1.6.0
Source:
Returns:
是否符合华为或荣耀设备特征。
Type
boolean

(static) isIOS(uaopt) → {boolean}

检查指定 useragent 字符串是否符合 iOS 系统特征。
Parameters:
Name Type Attributes Description
ua string <optional>
useragent 字符串,浏览器环境下默认为 navigator.userAgent。
Author:
  • luoliquan
Source:
Returns:
是否符合 iOS 系统特征。
Type
boolean

(static) isMobile(uaopt, featuresopt) → {boolean}

检查当前设备是否移动设备。
Parameters:
Name Type Attributes Description
ua string <optional>
useragent 字符串,浏览器环境下默认为 navigator.userAgent。
features Object <optional>
浏览器特征。
Properties
Name Type Attributes Description
platform string <optional>
运行平台。
maxTouchPoints string <optional>
最大触点数。
Author:
  • luoliquan
Source:
Returns:
当前设备是否移动设备。
Type
boolean
Example
isMobile(navigator.userAgent);
isMobile(navigator.userAgent, {
  platform: navigator.platform,
  maxTouchPoints: navigator.maxTouchPoints
});

(static) isWeixin(uaopt) → {boolean}

检查指定 useragent 字符串是否符合微信客户端特征。
Parameters:
Name Type Attributes Description
ua string <optional>
useragent 字符串,浏览器环境下默认为 navigator.userAgent。
Author:
  • luoliquan
Source:
Returns:
是否符合微信客户端特征。
Type
boolean

(static) isWorkWeixin(uaopt) → {boolean}

检查指定 useragent 字符串是否符合企业微信客户端特征。
Parameters:
Name Type Attributes Description
ua string <optional>
useragent 字符串,浏览器环境下默认为 navigator.userAgent。
Author:
  • luoliquan
Source:
Returns:
字符串是否符合企业微信客户端特征。
Type
boolean

(static) weixinVersion(uaopt) → {string}

获取指定 useragent 字符串中的微信版本号。
Parameters:
Name Type Attributes Description
ua string <optional>
useragent 字符串,浏览器环境下默认为 navigator.userAgent。
Since:
  • 1.6.0
Source:
Returns:
微信版本号,不符合微信特征时返回空字符串。
Type
string