兼容 IE6 下Tbody 的 innerHTML 只读无法赋值的问题

 1 function getUpgradeDetail(data)
 2 {
 3     $id("upgradeTbody1").style.display = "none";
 4     $id("upgradeTbody2").style.display = "none";
 5     $id("upgradeTbody3").style.display = "none";
 6     listData = data.slice(0-1);
 7     atmData  = data.slice(listData.length);
 8     
 9     var allHtml = "";
10     
11     for(key in listData)
12     {
13         if(listData[key]['attpk_guid']=="" ^ listData[key]['attpk_guid']==null)
14         {
15             //服务器
16             var html = $id("upgradeTbody1").innerHTML;
17             html = html.replace(/{id}/ig,parseInt(key) + 1);
18             html = html.replace(/{num}/ig,key);
19             html = html.replace(/{apk_model_name}/ig,listData[key].attpk_model_name);
20             html = html.replace(/{attpk_guid}/ig,listData[key].attpk_guid);
21             html = html.replace(/{apk_id}/ig,listData[key].attpk_id);
22             html = html.replace(/{apm_name}/ig,listData[key].attpm_name);
23             html = html.replace(/{apm_id}/ig,listData[key].attpm_id);
24             html = html.replace(/{apm_price}/ig,listData[key].usat_transprice);
25             html = html.replace(/{u_startdate}/ig,listData[key].usat_startdate);
26             html = html.replace(/{u_enddate}/ig,listData[key].usat_enddate);
27             html = html.replace(/{goods_no}/ig,"(" + $id("goods_no").value +")");
28             //$id("upgradeTbody").innerHTML = html;        //IE6出错,原因 tbody 在IE6是只读的
29             allHtml +=  html;
30         }else{
31             //非服务器
32             var html = $id("upgradeTbody2").innerHTML;
33             html = html.replace(/{id}/ig,parseInt(key) + 1);
34             html = html.replace(/{num}/ig,key);
35             html = html.replace(/{apk_model_name}/ig,listData[key].attpk_model_name);
36             html = html.replace(/{attpk_guid}/ig,listData[key].attpk_guid);
37             html = html.replace(/{apk_id}/ig,listData[key].attpk_id);
38             html = html.replace(/{apm_name}/ig,listData[key].attpm_name);
39             html = html.replace(/{apm_id}/ig,listData[key].attpm_id);
40             html = html.replace(/{apm_price}/ig,listData[key].usat_transprice);
41             html = html.replace(/{u_startdate}/ig,listData[key].usat_startdate);
42             html = html.replace(/{u_enddate}/ig,listData[key].usat_enddate);                    
43             //$id("upgradeTbody").innerHTML += html;   //IE6出错,原因 tbody 在IE6是只读的
44             allHtml +=  html;
45         }
46 
47     }
48     if(!-[1,])
49     {
50         allHtml = $id("upgradeTbody").parentNode.outerHTML.replace("</TBODY>",allHtml + "</TBODY>");
51         $id("upgradeTbody").parentNode.outerHTML = allHtml
52         $("#changetype2_" + key)[0].attachEvent("click",changetype2Event)
53     }else{
54         $id("upgradeTbody").innerHTML += html
55         $id("changetype2_" + key).addEventListener("click",changetype2Event,false);
56     }
57 }

 

posted @ 2010-08-14 15:38  chy1000  阅读(1760)  评论(0编辑  收藏  举报