IE really let the designer hate the tooth itch thing, and now has IE6, IE7, IE8, IE9, IE10 this five different versions of the browser, and there are a small difference. But there is no way to make the page appear in every browser as well as to accommodate it.
But now I am basically not willing to be compatible with the lower version of IE. such as IE6, IE7 these direct ignore! IE8 's words will do. Fortunately, IE9 and IE10 on the network standard support are compared, such as IE9 version of the browser after the popularization of good very good.
But do not do compatibility is not compatible, or to be simple to deal with. Luckily, JQuery provides a browser tag that allows us to determine what browsers and versions the current visitor is using:
<script type= "Text/javascript" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" ></ Script>
<script type= "Text/javascript" >
$ (function () {
var useragent = Window.navigator.userAgent.toLowerCase ();
var version = $.browser.version;
$ (". Info"). HTML (
"");
});
</script>
<body>
<div class= "Info" ></div>
</body>
I used a few simple examples to show the current browser useragent and JQuery.browser.version, and then in the IE 6~8 test, but the result of the display is really let out of amazement!
From the results, IE 7 is wrong to judge, in a careful look at its useragent will find that inside in addition to MSIE 7.0, but also contains a MSIE 6.0, so jQuery.browser.version than the right to have a problem. Now that we know the problem, we can solve the problem.
The first way is a more direct way, first to determine if there is a higher version of UserAgent, that is based on the main version:
When you want to use it, you can use $.BROWSER.MSIE6~10 to do the judgment processing. The other is to directly modify the JQuery.browser.version of the method:
<script type= "Text/javascript" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" > </script> <script type= "Text/javascript" > $ (function () {var useragent = Window.navigator.userAgent.toLowe
Rcase ();
$.browser.msie10 = $.browser.msie &&/msie 10.0/i.test (useragent);
$.BROWSER.MSIE9 = $.browser.msie &&/msie 9.0/i.test (useragent);
$.BROWSER.MSIE8 = $.browser.msie &&/msie 8.0/i.test (useragent);
$.browser.msie7 = $.browser.msie &&/msie 7.0/i.test (useragent); $.browser.msie6 =!$.browser.msie8 &&!$.browser.msie7 && $.browser.msie &&/msie 6.0/i.test (
useragent); $ (". Info"). HTML ("
After such a correction, when we use jQuery.browser.version to judge the correct display of IE version number. Both ways have their convenience, it depends on how you choose to use it!