Why is ‘event’ available globally in Chrome but not Firefox?

In IE, the event object was a global object, (which is not passed to the handler function) but accessed as a global object. You can also access it as a property of the window object like window.event

In in FF and other browsers the event object was passed as an argument, since in FF there is no global property called event, you are getting the error message.

In chrome they have added support for both these features, so you will get the event object as a global reference and as an argument.

But since you are using jQuery, jQuery normalizes these 2 behaviors and will always pass the event object as an argument to the event handler.

$(document).ready(function () {
    $("#uspsSideboxTrackingClose").click(function (event) {
        event.preventDefault();
        console.log(event);
    });
});

Leave a Comment