js determines browser type
$.browser object
$.browser.version browser version
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 above code directly into <script></script>
js determines that ie6 will not execute
if ($.browser.msie && $.browser.version <= 6.0)
return false;
$.browser.msie determines whether it is an ie browser
$.browser.version <= 6.0 determines whether ie is less than or equal to ie6
return flase will not be executed
For example, there is a piece of code that is a pop-up box. If IE6 does not execute it, but everything else is executed, the code can be operated 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
});
}
Another example, for example, if there is a piece of code, ie6 will not execute it, but everything else will. The code can be written as follows:
function webJs() {
if (!$.browser. msie && ($.browser.version != "6.0")) {
$("#fastNav li:gt(0)").hover(function () {
$(this).stop() .animate({ marginLeft: "10px" }, 'fast');
}, function () {
$(this).stop().animate({ marginLeft: "0px" }, 'fast' );
});
}
}