IE:"nodeType"为null或不是对象 [英] IE: ‘nodeType’ is null or not an object
问题描述
我在IE(6,7,8)中的网站上遇到此问题:
I'm having this issue on my website in IE (6,7,8):
"nodeType"为空或不是对象
‘nodeType’ is null or not an object
该错误涉及"f.nodeType"属性.基本上f是未定义的,因此问题已经存在,但是我无法解决.
The error refers to "f.nodeType" property. Basically f is undefined, so the issue is before, but I cannot fix it.
(从IE开发人员工具栏调试,它似乎是抛出错误的这一行)
(为了便于阅读,在下面展开了autocolumn.min.js line 13
)
(from IE developer toolbar debug it appears to be this line that is throwing the error)
(autocolumn.min.js line 13
expanded below for readability)
页面位于 http://www.donatellabernardi.ch/drupal
function split($putInHere,$pullOutHere,$parentColumn,height){
if($pullOutHere.children().length){
$cloneMe=$pullOutHere.children(":first");
$clone=$cloneMe.clone(true);
if($clone.attr("nodeType")==1&&!$clone.hasClass("dontend")){
^^^^^^^^^^^^^^^^^^^^^^^^^^ Chokes on
$putInHere.append($clone);
if($clone.is("img")&&$parentColumn.height()<height+20){
$cloneMe.remove();
}else if(!$cloneMe.hasClass("dontsplit")&&$parentColumn.height()<height+20){
$cloneMe.remove();
}else if($clone.is("img")||$cloneMe.hasClass("dontsplit")){
$clone.remove();
}else{
$clone.empty();
if(!columnize($clone,$cloneMe,$parentColumn,height)){
if($cloneMe.children().length){
split($clone,$cloneMe,$parentColumn,height);
}
}
if($clone.get(0).childNodes.length==0){
$clone.remove();
}
}
}
}
}
推荐答案
Using the "Firebug lite" Bookmarklet (you can get it here: http://getfirebug.com/firebuglite ), I could narrow down the place where the error actually is being thrown.
问题的根源似乎不在您提取的代码中,而是在jQuery本身中.
It seems that the root of the problem is not in the code that you've extracted, but in jQuery itself.
我注意到您正在使用jQuery 1.2.6版.问题是该版本的克隆方法.这会导致您发布的代码的这一行出现错误:
I noticed that you're using jQuery version 1.2.6. The problem is the clone-method of that version. This results in an error in this line of your posted code:
$clone=$cloneMe.clone(true);
我可以为您提供更多详细信息,确切说明错误发生的位置,但是我认为这不会解决您的问题.无论如何,为有缺陷的jQuery代码构建变通办法不是一个好主意.我宁愿建议尝试使用最新版本的jQuery(快速浏览后,我发现那里的clone-method实现方式有所不同),看看是否可以解决您的问题.
I could give you more details, where exactly the error happens, but I don't think that this will solve your problem. Anyway it's not a good idea to build a workaround for the flawed jQuery-code. I'd rather recommend to try a more recent version of jQuery (after a quick glance I saw that there the clone-method is implemented differently) and have a look if that solves your problem.
抱歉,不是这行
$clone=$cloneMe.clone(true);
但此行:
$cache.append($(this).children().clone(true));
(autocolumn.js中的第42行)
(line 42 in the autocolumn.js)
这篇关于IE:"nodeType"为null或不是对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!