Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.event.srcelement not working in firefox

Tags:

javascript

 _eventButtonElement = window.event.srcElement;

How can I solve that in firefox?

like image 959
zanhtet Avatar asked Dec 03 '22 10:12

zanhtet


2 Answers

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
};
like image 184
qwertymk Avatar answered Dec 23 '22 02:12

qwertymk


One of the cross Browser issues. Use this:

var evnt = event || window.event;
_eventButtonElement  = evnt.target || evnt.srcElement;
like image 20
Chandu Avatar answered Dec 23 '22 04:12

Chandu