//方式一 <script> if(navigator.userAgent.indexOf("MSIE")>0){ //是否是IE浏览器 if(navigator.userAgent.indexOf("MSIE 6.0")>0){ //6.0 使用1.CSS Css.innerHTML='<link href="1.css" rel="stylesheet" type="text/css" >' } if(navigator.userAgent.indexOf("MSIE 7.0")>0){//7.0 使用2.CSS Css.innerHTML='<link href="2.css" rel="stylesheet" type="text/css" >' } }else{//否则使用3.CSS 还有具体的浏览器 你可以用navigator.userAgent 去获取信息 具体使用 看你自己 Css.innerHTML='<link href="3.css" rel="stylesheet" type="text/css" >' } </script> //方式二 <script> function valie() { if(window.ActiveXObject){ alert("ie----"+window.ActiveXObject); } if(window.XMLHttpRequest){ alert("非ie------"+window.XMLHttpRequest); } } function chk() { if (navigator.appName.indexOf("Microsoft") != -1) { alert("ie"); } else { alert("火狐"); } } </script>
網上收集整理