日期:2014-05-16  浏览次数:20470 次

请教高手关于js兼容ie6的问题!!!
哪位高手能帮忙指点下如何让下面的js兼容ie6浏览器呢?

JScript code
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("navmall");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+="over";
}
node.onmouseout=function() {
this.className=this.className.replace("over", "");
}
node.onmouseover=function() {
this.className+="over";
this.getElementsByTagName("a")[0].style.backgroundColor="#736767";
this.getElementsByTagName("a")[0].style.color="#FFF";
}
node.onmouseout=function() {
this.className=this.className.replace("over", "");
this.getElementsByTagName("a")[0].style.backgroundColor="";
this.getElementsByTagName("a")[0].style.color="";
}}}}}
window.onload=startList;


------解决方案--------------------
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];

不要用childNodes 用 getElementsByTagName