.ull{
list-style-type:none;
}
.lii1{
float:left;
border-bottom-width:1px;
border-bottom-color:#ededed;
border-bottom-style:solid;
border-right-width:1px;
border-right-color:#ededed;
border-right-style:solid;
line-height:21px;
width:127px;
}
.lii2{
float:left;
border-bottom:1px solid #ededed; 
border-right:1px solid #ededed; 
line-height:21px;
width:71px; 
text-align:center;
}//获取Div ID
        var div1 = document.getElementById("rod");
        div1.setAttribute("style", "width:200px; display:inline; overflow: auto;");
        //创建Div2
        ul = document.createElement("ul");
        ul.setAttribute("class", "ull");
        ul.setAttribute("onclick", "GetLongitudeAndLatitude('" + temCarModel[i].TerminalID + "');");
        li1 = document.createElement("li");
        li1.width = "127px";
        li1.setAttribute("class", "lii1");
        div2 = document.createElement("div");
        div2 = document.createTextNode(temCarModel[i].PlateNum);
        li1.appendChild(div2);
        ul.appendChild(li1);
        li2 = document.createElement("li");
        li2.setAttribute("class", "lii2");
        li2.width = "71px";
        div3 = document.createElement("div");
        div3 = document.createTextNode(temCarModel[i].TerminalState);
        
        li2.appendChild(div3);
        ul.appendChild(li2);
        div1.appendChild(ul);
该JS代码运行后正常显示的列表效果为上图为在火狐或IE8浏览器上显示的列表效果,但在IE6浏览器上显示的效果为下图为的列表效果。
其中我发现JS在IE6运行后不会重新读取CSS样式的数据,只会直接显示JS列表的内容。
请问有JS怎么生成列表后再执行一下CSS?或者有其它的解决方面吗?ie6cssjs

解决方案 »

  1.   

    你这是在用不标准的代码,挑战ie不标准的规范
    微软的浏览器,它说能执行就执行,不能就不能,你也没办法,因为不规范div1.setAttribute("style", "width:200px; display:inline; overflow: auto;");

    div1.style.width = "200px";
    div1.style.display = "inline";
    这样的写法ul.setAttribute("onclick", "GetLongitudeAndLatitude('" + temCarModel[i].TerminalID + "');");
    要这样写
    ul.onclick = function(){};

    function test(){}
    ul.onclick = test;ul.setAttribute("class", "ull");
    这句,用以下写法
    ul.className = "ull";好么,试试吧亲
      

  2.   

    CSS都写到样式 里,直接用拼HTML就行了<style>
    li,ul{ list-style-type:none; padding:0;margin:0 }
    .ull{
    list-style-type:none;
    clear: both;
    width:200px;
    }
    .lii1{
    float:left;
    border-bottom-width:1px;
    border-bottom-color:#ededed;
    border-bottom-style:solid;
    border-right-width:1px;
    border-right-color:#ededed;
    border-right-style:solid;
    line-height:21px;
    width:127px;  
    }
    .lii2{
    float:left;
    border-bottom:1px solid #ededed; 
    border-right:1px solid #ededed; 
    line-height:21px;
    width:71px; 
    text-align:center;
    }
    #rod{
     
    width:200px; display:inline; overflow: auto;
    }
    </style>
    <div id="rod">

    </div><script>  
       function add (TerminalID,PlateNum,TerminalState ){
       var rod = document.getElementById("rod");
        html= '<ul class="ull" onclick="GetLongitudeAndLatitude('+TerminalID
          +')"  ><li class="lii1">'+ PlateNum
           +'</li><li class="lii2">' + TerminalState +'</li></ul>';
       rod.insertAdjacentHTML('beforeEnd',html);
       }
     window.onload=function(){
     add(1,'aa','离线');
     add(2,'bbb','离线');
     add(3,'cc','离线');
     } 
     function GetLongitudeAndLatitude(id){ alert(id) } 
    </script>