Node.TEXT_NODE和IE7 [英] Node.TEXT_NODE and IE7
问题描述
if(node.nodeType == Node) TEXT_NODE){
当然,在Firefox,Safari和Opera中都可以正常工作。但Internet Explorer 7正在抱怨 Node
(具有大写字母N)未定义。但这是 DOM Level 2 的一部分! / p>
我真的需要更改我的代码才能使用魔术数字吗?或者我在这里缺少一些简单的东西?
不幸的是,你没有丢失任何东西。
IE中没有Node常量。看这里 http://www.ibm.com/developerworks/xml/library /x-matters41.html 在你还能用DOM做什么?。
所以要么定义自己的Node常量,要么简单请求
node.nodeType === 3
I've some javascript that tests DOM node types against like this:
if(node.nodeType == Node.TEXT_NODE) {
Of course, it all works fine in Firefox, Safari, and Opera. But Internet Explorer 7 is complaining that Node
(with the capital N) is undefined. But that's part of DOM Level 2!
Do I really need to change my code to use magic numbers? Or am I missing something simple here?
Unfortunately you are not missing anything.
There is no Node constant in IE. Look here http://www.ibm.com/developerworks/xml/library/x-matters41.html at section "What else can you do with the DOM?".
So either you define your own Node constant or you simply ask for
node.nodeType === 3
这篇关于Node.TEXT_NODE和IE7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!