return (Array) borwser
For example, the current browser type is ie6.0, then the value of borwser should be ["ie", "6", "6.0"]
The first value of the array represents the browser Type, the second value represents the large version of the browser, and the third value represents the detailed version number of the browser.
/**
* @author sky
*/
var browser = function()
{
//The default is ie6
var _a = ["ie", "6", "6.0"];
var _s = false;
var _ua = navigator.userAgent.toLowerCase();
//Detection regularity
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;
}(),
Simple demonstration: the above code should be one of the multiple methods in the framework
]<script>
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;
}()
var dd =browser;
alert(dd[0]+" "+dd[1]+" "+dd[2]);
</script>