stopPropagation() not working in Firefox

In IE this function works (shows the calendar and allow click outside to close the calendar)
but it does not work in FF. (The calendar do not appear) any ideas?

function showCalendarControl(textField) {
  if (!e) var e = window.event;
            e.cancelBubble = true;
            if (e.stopPropagation) e.stopPropagation();
  calendarControl.show(textField);
 
}
ercantuncAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HainKurtSr. System AnalystCommented:
is this running fine?

function showCalendarControl(textField) {
  calendarControl.show(textField);
}
HainKurtSr. System AnalystCommented:
if not, then ask the developer for calendarControl ;)
HainKurtSr. System AnalystCommented:
do you have a link to share with us so we can test?
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

ercantuncAuthor Commented:
Sure it runs, but I it is not possbile to share
Samuel LiewCommented:
This is happening because you are not passing the event (e) variable into the function.
function doSomething(e) {
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}
yourElement.onclick = doSomething;

Open in new window

ercantuncAuthor Commented:
Ok I got it but in your example you do not pass it
 ith should be something like this right?

yourElement.onclick = doSomething(somethinghere?) ;
 
Samuel LiewCommented:
No, the event is automatically passed to the function.
ercantuncAuthor Commented:
This works in IE but in FF gives "e  is undefined error"

function showCalendarControl(textField) {
  calendarControl.show(textField);
 }
function stopProp(e){  
            if (!e) var e = window.event;
            e.cancelBubble = true;
            if (e.stopPropagation) e.stopPropagation();
}
onclick="showCalendarControl(this);stopProp();"
ercantuncAuthor Commented:
I corrected like this now there is  no error but still do not work in FF

onclick="showCalendarControl(this);stopProp;"
Samuel LiewCommented:
try this
function stopProp(e) {
  var event = e || window.event;
  if (event.stopPropagation) {
    event.stopPropagation();
  } else {
    event.cancelBubble = true;
  } 
}

Open in new window

ercantuncAuthor Commented:
now it says event is undefined, IE works
ercantuncAuthor Commented:
This worked below, thank you

onclick="stopProp(event);"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.