Home >Web Front-end >JS Tutorial >js does not execute when it determines that the browser type is ie6_javascript skills

js does not execute when it determines that the browser type is ie6_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:44:401066browse

js determines browser type

$.browser object
$.browser.version browser version

Copy code 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 above code directly into <script></script>

js determines that ie6 will not execute
Copy code The code is as follows:

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:
Copy code 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
});
}

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:
Copy code 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" }, 'fast');
}, function () {
$(this).stop().animate({ marginLeft: "0px" }, 'fast' );
});
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn