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 8.0")>0){ alert("ie8浏览器"); } if(navigator.userAgent.indexOf("MSIE 9.0")>0){ alert("ie9浏览器"); } } //判断浏览器版本低于IE8 if(navigator.userAgent.indexOf("MSIE")>0){ if(navigator.userAgent.indexOf("MSIE 6.0")>0 || navigator.userAgent.indexOf("MSIE 7.0")>0 || navigator.userAgent.indexOf("MSIE 8.0")>0){ alert(alert("低于ie8浏览器"); ) } }
//判断是否为移动端设备 var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire"); var browser = navigator.userAgent.toLowerCase(); var isMobile = false; for (var i=0; i<mobileAgent.length; i++){ if (browser.indexOf(mobileAgent[i])!=-1){ isMobile = true; $(".bodya .u1").css("background","green"); } }