This article mainly introduces how to judge the browser type of js and how to not execute the browser type when the type is ie6. If you need it, refer to js to determine the browser type.
$. Browser object
$. Browser. version browser version
The Code is as follows:
Var binfo = '';
If ($. browser. msie) {binfo = "Microsoft Internet Explorer" + $. browser. version ;}
Else if ($. browser. mozilla) {binfo = "Mozilla Firefox" + $. browser. version ;}
Else if ($. browser. safari) {binfo = "Apple Safari" + $. browser. version ;}
Else if ($. browser. opera) {binfo = "Opera" + $. browser. version ;}
Else {
Binfo = "google ";
}
Alert (binfo );
Write the code above to script and script.
Js judges ie6 is not executed
The Code is as follows:
If ($. browser. msie & $. browser. version <= 6.0)
Return false;
$. Browser. msie determine whether it is an IE browser
$. Browser. version <= 6.0 judge that ie is less than or equal to ie6
Return flase
For example, a piece of code is a pop-up box. If ie6 is not executed and all others are executed, the code can be operated as follows:
The Code is as follows:
Function nextPopBox1 (){
If ($. browser. msie & $. browser. version <= 6.0)
Return false;
Layer. closeAll ();
$. Layer ({
Type: 1,
Shade: [0.5, '# 000', true],
Border: false,
Bgcolor :'',
Fix: false,
Title: false,
Page: {dom: '# img2 '},
Area: ['724px ', '302px'],
CloseBtn: false
});
}
In another example, for example, there is a piece of code, ie6 is not executed, and all others are executed. The code can be written as follows:
The Code is as follows:
Function webJs (){
If (! $. Browser. msie & ($. browser. version! = "6.0 ")){
$ ("# FastNav li: gt (0)"). hover (function (){
$ (This). stop (). animate ({marginLeft: "10px"}, 'save ');
}, Function (){
$ (This). stop (). animate ({marginLeft: "0px"}, 'save ');
});
}
}