0
function expand(entity) {
    var oImage

    oImage = entity.childNodes(0).all["image"]

    oImage.src = entity.imageOpen

    if (typeof(entity.imageOpen) == "undefined")
        oImage.src = "<%=request.getContextPath()%>/images/MinusSignBlackSilver.gif";

    for(i=0; i < entity.childNodes.length; i++) {
        if(entity.childNodes(i).tagName == "DIV") {
            entity.childNodes(i).style.display = "block"
        }
    }
    entity.open = "true"
} 

is working fine on IE. But in Mozilla gives error entity.childNodes is not a function. What is the right syntax to work properly in IE and Mozilla?

4

1 回答 1

1

childNodes是一个类似数组的对象。尝试entity.childNodes[0]代替(0).

此外.all,它是 IE 特定的功能,不是规范的一部分。您应该将其替换为任querySelectorAll一或其他(向后兼容)功能。

参考https ://developer.mozilla.org/pl/docs/DOM/element.childNodes

于 2013-01-17T12:33:33.183 回答