Reputation: 2050
_eventButtonElement = window.event.srcElement;
How can I solve that in firefox?
Upvotes: 4
Views: 8441
Reputation: 21
This should work: _eventButtonElement = window.event.srcElement || window.event.originalTarget;
originalTarget is the firefox equivalent to srcElement.
Upvotes: 2
Reputation: 35276
Firefox uses an event argument that gets passed into an event function
Change your code from this:
window.onload = function() {
//CODE
_eventButtonElement = window.event.srcElement;
//CODE
};
To this:
window.onload = function(e) {
//CODE
_eventButtonElement = window.event.srcElement || e.target;
//CODE
};
Upvotes: 10
Reputation: 82903
One of the cross Browser issues. Use this:
var evnt = event || window.event;
_eventButtonElement = evnt.target || evnt.srcElement;
Upvotes: 5