Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  4] [ 3]  / answers: 1 / hits: 32055  / 9 Years ago, thu, march 19, 2015, 12:00:00

All other browsers work perfectly fine. However, when firefox tries to execute this code:



if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();


it crashes and the console displays the following error:
TypeError: e is undefined






edit 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();
}


What it does it, change the style of a div when clicked and hides all other divs from the class. When someone clicks the x that's inside the div, it should change the style back and show the hidden divs.


More From » jquery

 Answers
17

e is not defined so that would be the error



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();
}


If you used jQuery to attach the event, there is no reason to be doing the check for event or stopPropagation.


[#67380] Tuesday, March 17, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leslijessalyng

Total Points: 650
Total Questions: 85
Total Answers: 109

Location: Croatia
Member since Mon, Sep 6, 2021
3 Years ago
leslijessalyng questions
Fri, Feb 21, 20, 00:00, 4 Years ago
Tue, Jul 30, 19, 00:00, 5 Years ago
Fri, Jul 5, 19, 00:00, 5 Years ago
Wed, Mar 13, 19, 00:00, 5 Years ago
;