(function(){
={};
var ua=();
//First let’s take a look at what the three browsers have returned to.
//ie ua=mozilla/4.0 (compatible; msie 8.0; windows nt 5.2; trident/4.0; qqpinyin 730; .net clr 1.1.4322)
//firefox ua=mozilla/5.0 (windows; u; windows nt 5.2; zh-cn; rv:1.9.2) gecko/20100115 firefox/3.6
//chrome ua=mozilla/5.0 (windows; u; windows nt 5.2; en-us) applewebkit/532.5 (khtml, like gecko) chrome/4.0.249.0 safari/532.5
//You can see the browser above IE msie 8.0 firefox firefox/3.6 chrome chrome/4.0.249
//We can just use regular to find out which browser it can match these key points in the string.
//Look at the regular expression of the firefox below /firefox\/([\d\.]+)/
//firefox\/ Matches a firefox/ such a character
//([\d\.]+) () means that the matching characters need to be captured. It is his credit that you can use [1] to obtain the version number later.
//[] means to enclose \d\. as a whole. There is no other meaning.
//\d Match a number \. Match one . Add it together to match 8. Such a thing
//[]+ [] There is another + outside, he will repeat the matched things inside [], so it becomes like this. 8.8.8.8. Of course, this is OK. 48.1.563
=(/firefox\/([\d\.]+)/);
=(/msie\s([\d\.]+)/);
//msie\s([\d\.]+)
// I'm basically the same as Firefox, there's no big difference
// msie 8.0 \s is to match a space between msie and 8.0
=(/chrome\/([\d\.]+)/);
//chrome\/([\d\.]+)
//Same as Firefox
})();
//use
if(){
alert(true)
}else{
alert(false)
}
if([1]=="8.0"){
alert(true)
}else{
alert(false)
}
alert();
alert();
alert();
//Only the current browser's sys can use [1] to return the version number
alert([1]);
//alert([1]);
//alert([1]);