Why is 'event' available globally in Chrome but not FF?

妖精的绣舞 提交于 2019-11-26 23:15:59

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);
    });
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!