js判斷瀏覽器載入對應CSS

來源:互聯網
上載者:User

<script language="javascript">
if(window.navigator.userAgent.indexOf("MSIE 6.0")>=1){
  //如果瀏覽器為IE
  setActiveStyleSheet("style1.css");
}
else if(window.navigator.userAgent.indexOf("MSIE 7.0")>=1){
  //如果瀏覽器為Firefox
  setActiveStyleSheet("style2.css");
}
else if(window.navigator.userAgent.indexOf("Firefox")>=1){
  //如果瀏覽器為Firefox
  setActiveStyleSheet("style3.css");
}
else{
  //如果瀏覽器為其它
  setActiveStyleSheet("style4.css");
}


function setActiveStyleSheet(filename){
 
   document.write("<link href=/"//css//"+filename+"/" type=/"text//css/" rel=/"stylesheet/">");

}
</script>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.