var cellTr = document.createElement("tr");
var cellTd = document.createElement("td");
cellTd.appendChild(document.createTextNode("用戶名:"+userName));
cellTr.appendChild(cellTd);
cell.appendChild(cellTr);
cellTd = document.createElement("td");
cellTd.appendChild(document.createTextNode("創建時間:+userCreateDate"));
cellTr.appendChild(cellTd);
cell.appendChild(cellTr);
cellTd = document.createElement("td");
cellTd.appendChild(document.createTextNode("發表文章:"+articleCount));
cellTr.appendChild(cellTd);
cell.appendChild(cellTr);
row.appendChild(cell);
cell = document.createElement("td");
cellTr = document.createElement("tr");
cellTd = document.createElement("td");
cellTd.appendChild(document.createTextNode("發表時間:"+creationDate+" "+"修改時間:"+modifiedDate));
cellTr.appendChild(cellTd);
cell.appendChild(cellTr);
cellTr = document.createElement("tr");
cellTd = document.createElement("td");
cellTd.appendChild(document.createTextNode(subject));
br = document.createElement("br");
cellTd.appendChild(br);
cellTd.appendChild(document.createTextNode(body));
cellTr.appendChild(cellTd);
cell.appendChild(cellTr);
row.appendChild(cell);
document.getElementById("messageList").appendChild(row);
}
以上代碼在ie中出現"意外的調用了方法或屬性訪問",錯誤指向最后一句.望各大俠指點迷津
評價:
你這段代碼感覺不優雅~沒有重用性~性能底~、
建議:
1>采用函數封裝實現重用。
2>對于table的內部嵌套采用如下格式:
對table動態生成,采用從內到外添加的方案。另盡可能少使用document.createTextNode,性能低。
3>如果你的table不是在頁面加載時需要執行,建議在
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com