本帖最后由 yiyekuanghuan 于 2009-09-30 09:59:07 编辑

解决方案 »

  1.   

    <!--[if IE 6]> 
    只有ie6用户可以看到这里的内容哟 
    <![endif]--> <!--[if IE 7]> 
    只有ie7用户可以看到这里的内容哟 
    <![endif]--> 
      

  2.   


    <style>
    .ie6{display:none !important;_display:block;}
    .ie7{display:block !important;_display:none;}
    </style>
    <!--[if gt IE 6]>
    <style>
    .ie6{display:none;}
    .ie7{display:block;}
    </style>
    <![endif]-->
    <div class="ie6"> 
    只有ie6用户可以看到这里的内容哟 
    </div> <div class="ie7"> 
    只有ie7、ie8、firefox、chrome、Safari等非ie6用户可以看到这里的内容哟 
    </div>
      

  3.   

    function CheckBrowser()
    {
      var app=navigator.appName;
      var verStr=navigator.appVersion;
      if (app.indexOf('Netscape') != -1) {
        alert("你使用的是Netscape浏览器或火狐浏览器。");
      }
      else if (app.indexOf('Microsoft') != -1) {
        if (verStr.indexOf("MSIE 3.0")!=-1 || verStr.indexOf("MSIE 4.0") != -1 || verStr.indexOf("MSIE 5.0") != -1 || verStr.indexOf("MSIE 5.1") != -1) {
          alert("您使用的是低版本(IE6.0以下)的浏览器.");    } else {alert("您使用的是IE6.0以上的浏览器.");}
      }
    } 对同一类浏览器可以使用版本来看是什么浏览器,比如IE6,IE7
    其它的就直接可以通过appName判断了
      

  4.   

    顶hookee,<!--[if gt IE 6]>换成<!--[if ! IE 6]>可能更好点^_^
      

  5.   

    发个JS版的^_^
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>不同浏览器查看不同内容</title>
    <script>
    //添加样式
    var addSheet = function(){   
    var doc,cssCode;  
    if(arguments.length == 1){    
    doc = document;    
    cssCode = arguments[0]  
    }else if(arguments.length == 2){    
    doc = arguments[0];    
    cssCode = arguments[1];  
    }else{     
    alert("addSheet函数最多接受两个参数!");   
    }  
    if(!+"\v1"){//增加自动转换透明度功能,用户只需输入W3C的透明样式,它会自动转换成IE的透明滤镜   
    var t = cssCode.match(/opacity:(\d?\.\d+);/);    
    if(t!= null){       
    cssCode = cssCode.replace(t[0], "filter:alpha(opacity="+ parseFloat(t[1]) * 100+")")     
    }   
    }  
    cssCode = cssCode + "\n";//增加末尾的换行符,方便在firebug下的查看。  
    var headElement = doc.getElementsByTagName("head")[0]; 
    var styleElements = headElement.getElementsByTagName("style"); 
    if(styleElements.length == 0){//如果不存在style元素则创建     
    if(doc.createStyleSheet){    //ie       
    doc.createStyleSheet();   
    }else{       
    var tempStyleElement = doc.createElement('style');//w3c       
    tempStyleElement.setAttribute("type", "text/css");      
    headElement.appendChild(tempStyleElement);   
    }   
    }   
    var  styleElement = styleElements[0]; 
    var media = styleElement.getAttribute("media");  
    if(media != null && !/screen/.test(media.toLowerCase()) ){    
    styleElement.setAttribute("media","screen"); 

    if(styleElement.styleSheet){    //ie    
    styleElement.styleSheet.cssText += cssCode; 
    }else if(doc.getBoxObjectFor){   
    styleElement.innerHTML += cssCode;//火狐支持直接innerHTML添加样式表字串  
    }else{    
    styleElement.appendChild(doc.createTextNode(cssCode)) 

    }//判断浏览器
    var userAgent = navigator.userAgent.toLowerCase();
    var is_opera  = (userAgent.indexOf('opera') != -1);
    var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == "Apple Computer, Inc."));
    var is_webtv  = (userAgent.indexOf('webtv') != -1);
    var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
    var is_ie6     = ((userAgent.indexOf('msie 6') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
    var is_firefox  = ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function"));
    if(is_ie6){
    addSheet(".ie6{display:block;}.notie6{display:none;}");
    }else{
    addSheet(".ie6{display:none;}.notie6{display:block;}");
    }
    </script>
    </head><body>
    <div class=ie6> 
    只有ie6用户可以看到这里的内容哟 
    </div> <div class=notie6> 
    只有ie7、ie8、firefox、chrome、Safari等非ie6用户可以看到这里的内容哟 
    </div> 
    </body></html>
      

  6.   

    呵呵,这样的问题,最简单的就是用CSS了
    没必要再用JS来判断了
    css的话,只要一个class就应该可以搞定了