Return (Array) borwser
For example, the current browser type is ie6.0, then the Borwser value should be ["ie", "6", "6.0"]
The first value of the array represents the type of browser, the second value represents a large version of the browser, and the third value represents the detailed version number of the browser.
Copy Code code as follows:
/**
* @author Sky
*/
var browser = function ()
{
Default is IE6
var _a = ["ie", "6", "6.0"];
var _s = false;
var _ua = Navigator.userAgent.toLowerCase ();
Detect regular
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 Demo: The above code should be one of several methods in the framework
<script> var browser = function () {//default = IE6 var _a = ["ie", "6", "6.0"]; var _s = false; var _ua = Navigator.userAgent.toLowerCase (); Detect regular 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>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]