Differences between browsers, such as the window.event that does not work in Firefox

While the window.event was correctly evaluated on Chrome and IE, Firefox gave the error "ReferenceError:Event is not defined".
1 answer

Window.event does not exist in Firefox. Different browsers have different event models. Firefox handles the events slightly different IE and Chrome and for that reason it has not worked. A work-around is to pass the event as an argument to the function:
<a onclick="testfunction(event);">
 //...
</a>

testfunction(e){
 evt = e || window.event;
 //...
}

or use a library like jQuery to avoid dealing with all the differences between the browsers.

Comments

The answer give information why does the problem occur and that helps understanding it. But a little more description what "the function" does would have been very nice to understand the solution easily.

Boian Velitchkov - Sun, 12/02/2018 - 20:56 :::