TypeError:e未定义-javascript
所有其他浏览器都工作得很好。但是,当firefox尝试执行此代码时:TypeError:e未定义-javascript,javascript,jquery,html,firefox,Javascript,Jquery,Html,Firefox,所有其他浏览器都工作得很好。但是,当firefox尝试执行此代码时: if (!e) var e = window.event; e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); 它崩溃,控制台显示以下错误: 类型错误:e未定义 编辑1: function clickInactiveTab() { $(this).attr({class: "activeTab"}); $(".inactiv
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
它崩溃,控制台显示以下错误:
类型错误:e未定义
编辑1:
function clickInactiveTab() {
$(this).attr({class: "activeTab"});
$(".inactiveTab").hide();
}
function clickX() {
$(this).parent().attr({class: "inactiveTab"});
$(".inactiveTab").show();
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
它的作用是,在单击时更改一个div的样式,并对类隐藏所有其他div。当有人单击div中的x时,它应该将样式更改回原来的状态,并显示隐藏的div。e未定义,因此可能是错误
function clickX(e) { //e needs to be in the arguments as long as the event is attached properly, this will work.
$(this).parent().attr({class: "inactiveTab"});
$(".inactiveTab").show();
e = e || window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
如果使用jQuery附加事件,则没有理由检查事件或stopPropagation 你有一个内联处理程序?@Teemu我不确定你所说的内联处理程序是什么意思,但如果你所说的内联处理程序是指类似onClick=“”,不,我不知道,我指的是HTML代码中的
onXXXX
属性。请从头开始显示函数以及如何调用它。window.event
在firefox上未定义。关于你的问题,你应该提供更多的上下文。嗯,e
没有定义!因此出现了错误。e=e | | window.event代码>因为无论如何window.event
没有在FF上定义,使用新事件(类型)
?真的@A.Wolff?从document.layers和NN4天开始就是这样做的。如果e
参数未定义,它仍将处于FF状态。我认为最让人困惑的是OP在这里使用他的代码得到了他期望的东西。它的东西e
将在FF上定义,检查只支持旧IE,对吗?