时间:2021-07-01 10:21:17 帮助过:4人阅读
/**
* @author sky
*/
var browser = function()
{
//默认为ie6
var _a = ["ie", "6", "6.0"];
var _s = false;
var _ua = navigator.userAgent.toLowerCase();
//检测正则
var _pat = {
opera: /opera.([\d.]+)/,
ie: /msie ([\d.]+)/,
ff: /firefox\/([\d.]+)/,
chrome: /chrome\/([\d.]+)/,
safari: /safari\/([\d.]+)/,
mozilla: /rv:([\d.]+).+gecko/
};
for (var _t in _pat)
{
var _s = _ua.match(_pat[_t]);
if (_s)
{
_a = [_t, parseInt(_s[1]), _s[1]];
break;
}
}
return _a;
}(),
简单演示:上面的代码应该框架中多个方法的一个
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]