Javascript Dom数操作 的一点怪现象
今天在做项目时遇到一个很奇怪的问题在Javascript里创建Dom树时
var oFragment = document.createDocumentFragment();
var table = document.createElement("table");
table.style.width = "638px";
table.setAttribute("border", "0px");
table.setAttribute("cellpadding", "0px");
table.setAttribute("cellspacing", "1px");
table.setAttribute("bgcolor", "#C0B8A4");
oFragment.appendChild(table);
var thead = document.createElement("thead");
table.appendChild(thead);
var tr = document.createElement("tr");
thead.appendChild(tr);
.....
里面有这样一句话:table.setAttribute("bgcolor", "#C0B8A4");
这句话是设定表格的背景色,
可是我这样设定之后,
在ie8里有背景色,我用ie8的兼容模式就发现背景色没有,在ie6里没有背景色,
后来我把大小写改一下,改成
table.setAttribute("bgColor", "#C0B8A4");
结果在ie8,ie8兼容模式,ie6背景色都有设定成功。
结论好像是ie的不同版本的大小写的问题
但是我后来又做了一个实验,
在html页面在表格里用如下代码
....
<td width="90" height="75" align="left" valign="top" bgcolor="#FFFFFF">
.....
可是这里的bgcolor却不区分大小写
所以我也不知道是为什么,
只能说以后用javascript操作dom树的时候,注意大小写,无奈了
页:
[1]