未捕获的类型错误:无法读取未定义的属性“nodeName" [英] Uncaught TypeError: Cannot read property 'nodeName' of undefined
问题描述
这个问题只出现在joomla -
this problem appears only in joomla -
我正在尝试在我的 joomla 网站上使用 contentflow 插件
im trying to use the contentflow plugin with my joomla site
这是插件站点 - http://www.jacksasylum.eu/ContentFlow/
这是我的网站 - http://2-dweb.com/RND/
如您所见,它不起作用 - 它永远停留在加载阶段
as you can see it doesnt work - it just stays on the loading phase forever
经过仔细检查,我可以看到此代码存在问题:
upon closer inspection i can see that there is a problem with this code:
if (this.content.nodeName == "IMG") {
CFobj._imagesToLoad++;
var foobar = function () {
CFobj._imagesToLoad--;
this.image = this.content;
this.setImageFormat(this.image);
if ( CFobj.conf.reflectionHeight > 0) {
this.addReflection();
}
this.initClick();
CFobj._addItemCueProcess(true);
}.bind(this);
if (this.content.complete && this.content.width > 0)
window.setTimeout(foobar, 100);
else if (this.Browser.IE && !this.content.onload) {
var self = this;
var t = window.setInterval( function () {
if (self.content.complete && self.content.width > 0) {
window.clearInterval(t);
foobar();
}
}, 10);
}
else
this.content.onload = window.setTimeout(foobar, 100);
}
else {
this.initClick();
CFobj._addItemCueProcess(true);
}
};
第一行 - 它说未捕获的类型错误:无法读取未定义的属性‘nodeName’"
with the first line - it says "Uncaught TypeError: Cannot read property 'nodeName' of undefined "
但是这个东西在我的桌面 html 文件和插件站点上都有效!
but this thing works on my desktop html file and on the plugin site it self!
为什么它在我的 joomla 网站上不起作用?这不是冲突 - 我使用无冲突,我有其他有效的 jquery 插件
why doesnt it work on my joomla site? its not a conflict thing - im using no-conflict and i have other jquery plugins that work
更新:
rob w 帮我解决了这个错误:"将第一行改为 if (this.content && this.content.nodeName == "IMG") {.这样就解决了问题"
rob w helped me with this error: "Change the first line to if (this.content && this.content.nodeName == "IMG") {. That solves the problem"
确实如此,但现在出现另一个错误:
and it did, but now another error appears:
initClick: function () {
var cItem = this.clickItem;
this[this._activeElement].addEvent('click', cItem, false);
},
错误 - 未捕获的类型错误:无法调用未定义的方法addEvent"
the error - Uncaught TypeError: Cannot call method 'addEvent' of undefined
推荐答案
如错误解释Uncaught TypeError: Cannot read property 'nodeName' of undefined" 当脚本尝试访问该元素时,该元素不可用.您可以通过两种方式解决此问题.
As the error explains "Uncaught TypeError: Cannot read property 'nodeName' of undefined " The element is not available when the script tries to access it. You can solve this in two ways.
- 尝试使用 document.ready 包装代码.
- 您可以在访问之前检查该元素是否可用.要完成此操作,请使用 if 子句.
这篇关于未捕获的类型错误:无法读取未定义的属性“nodeName"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!