Why Firefox says that window.event is undefined? (call function with added event listener)

try getting the event using the parameter passed (named e in this case). i tested this and both window.event and the e is supported in chrome.

try checking for both, whichever exists

var ex = {
  exampl: function(e){

    console.log(window.event);
    console.log(e);  

    //check if we have "e" or "window.event" and use them as "evt"
    var evt = e || window.event    

  }
}

window.event is not a feature, it's a bug!

Quoting MDN:

window.event is a proprietary Microsoft Internet Explorer property which is only available while a DOM event handler is being called. Its value is the Event object currently being handled.

And most importantly:

Not part of any specification.

window.event is non-standard, so don't expect any browsers to support it.

First parameter of callback function in element.addEventListener() is an Event object. Use it instead of window.event.


Because window.event doesn't exist in Firefox. That's because browser have different event models and you'll have to deal with their differences or use a library like jQuery not to have to deal with all the differences between browsers. Welcome to the DOM.