2

许多 Javascripts 函数在 IE 9 中不起作用。

具体来说,我们动态构建了一些 HTML 内容。现在,当我们尝试使用 childNode 元素访问 HTML 表的内容时,对象并没有完全检索到其中。

但是,当我们在 IE 9 兼容模式下运行它时,我们能够得到它。

代码示例:

       var _object = document.getElementById(strTableId).childNodes[0]
       for (var iCount = 0; iCount < _object.childNodes.length; iCount++) {
            if (_object.childNodes[iCount]) {
                _object.childNodes[iCount].style.backgroundColor = 'white';
                _object.childNodes[iCount].style.color = 'black'
            }
        }

现在,当我们调试代码时,我们可以看到变量中存在的对象,但样式属性和其他属性无法访问。因此,backgroundcolor 行会引发 javascript exeption。

请帮忙!

4

1 回答 1

-1

IE 9 不支持 ChildNodes[0]。我们可以使用 children[0] 而不是 ChildNodes[0]

莫汉

于 2012-12-21T08:56:30.477 回答