转: 根据屏幕分辨率,浏览器调用不同css

<link type="text/csss" href="" rel="stylesheet"/>

<link type="text/csss" href="" rel="stylesheet"/>

<link type="text/csss" href="" rel="stylesheet"/>

<script type="text/javascript">

if (window.navigator.userAgent.indexOf("MSIE")>=1) 
  { 
    var ie600="ie1.css"; 
    var ie768="ie2.css"; 
    var ie864="ie3.css";
    var ie960="ie4.css"; 
    var ieOtherother="ie6.css";
    ScreenWidth(ie600,ie768,ie864,ie960,ieOtherother);
  }else{ 
   //if (window.navigator.userAgent.indexOf("Firefox")>=1) { 
    //如果浏览器为Firefox 
   // var Firefox1024="style1"; 
   // var Firefox800="style2.css"; 
   // var Firefox1152="css1.css"; 
   // var Firefoxother="css1.css"; 
   // ScreenWidth(Firefox1024,Firefox800,Firefox1152,Firefoxother); 
   //}else{ 
    //如果浏览器为其他 
    var Other600="qita1.css"; 
    var Other768="qita2.css"; 
    var Other864="qita3.css";
    var Other960="qita4.css";
    var Otherother="qita.css";
    ScreenWidth(Other600,Other768,Other864,Other960,Otherother); 
   //} 
  } 
  function ScreenWidth(CSS1,CSS2,CSS3,CSS4,CSS5){ 
   if (screen.height <= 600){ 
    setActiveStyleSheet(CSS1); 
   }else{
    if((screen.height>=600) && (screen.height<=768)){
     setActiveStyleSheet(CSS2);
    }else{
     if ((screen.width >=768) && (screen.height <=864 )){ 
      setActiveStyleSheet(CSS3); 
     }else{ 
      if ((screen.height >= 864) && (screen.height <=960 )){ 
       setActiveStyleSheet(CSS4); 
      }else{ 
       setActiveStyleSheet(CSS5);
      }
     }
    } 
    
   } 
  } 
  function setActiveStyleSheet(title){document.getElementsByTagName("link")[2].href="<%=path %>consultantHelp/css/"+title;}  
  <!--
   //根据浏览器来选择CSS
  // if (!window.XMLHttpRequest) {
  //  setActiveStyleSheet("ie6.css"); //IE6
  // }else if(window.ActiveXObject){
  //  setActiveStyleSheet("ie6.css"); //IE7
  // } else {
  //  setActiveStyleSheet("qita.css"); //Mozilla FireFox、Safari, etc.
  // }
  // function setActiveStyleSheet(filename){
  //  document.getElementsByTagName("link")[2].href="<%=path %>consultantHelp/css/"+filename; 
  // }
   -->
 </script>

posted @ 2013-10-28 11:29  Jearay  阅读(386)  评论(0编辑  收藏  举报