In the morning, originally wanted to do a position:fixed in various browsers compatible scenarios, but found IE7/8 below the position:fixed only support a screen, if the content height of more than one screen will not be good use of position: Fixed (if the classmate has position:fixed the perfect scheme trouble give me a bit), so I want to use JS to be compatible, in fact, is through scroll monitoring to achieve, so need to judge Ie7/8 these two versions, but found the $ of jquery. Browser.version does not support IE8, so I Baidu, Baidu is to give a lot of answers, but found IE8 still can not detect, and later I see navigator.useragent this thing, in each browser hit out is this look like:
//ie9 : Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
//ie8 : Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
//ie7 : Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; Tablet PC 2.0; .NET4.0E; .NET4.0C)
//Mozi: Mozilla/5.0 (Windows NT 6.1; rv:20.0) Gecko/20100101 Firefox/20.0
//goog: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
//oper: Opera/9.80 (Windows NT 6.1; Edition IBIS) Presto/2.12.388 Version/12.14
//appl: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
|
You find that IE8 and IE9 are the same, It seems that the light on this navigator.useragent is not enough, but I believe you will soon know how to do, because I9 is still a more advanced browser, with some IE8 not the properties, I do not list, one is Window.innerwidth, this property value is the browser inside height (excluding toolbars and scroll bars, or a more useful property). IE8 below this property value is undefined,9 below OK, display is a number. So it is natural to judge the browser version, see the following scenario:
if (Navigator.userAgent.indexOf ("MSIE") >0) { if (navigator.userAgent.indexOf ("MSIE 6.0") >0) { alert (" IE6 "); } if (Navigator.userAgent.indexOf ("MSIE 7.0") >0) { alert ("IE7"); } if (Navigator.userAgent.indexOf ("MSIE 9.0") >0 &&!window.innerwidth) {//Here is the focus, you know the alert ("IE8"); } if (Navigator.userAgent.indexOf ("MSIE 9.0") >0) { alert ("IE9"); }
Determine IE browser 7, 8, 93 versions (RPM)