Window.event.srcelement does not work in firefox

 _eventButtonElement = window.event.srcElement;

How can I solve this in firefox?

+3
source share
3 answers

Firefox uses an event argument, which is passed to the event function

Change your code:

window.onload = function() {
    //CODE
    _eventButtonElement = window.event.srcElement;
    //CODE
};

For this:

window.onload = function(e) {
    //CODE
    _eventButtonElement = window.event.srcElement || e.target;
    //CODE
};
+9
source

One of the problems with the browser. Use this:

var evnt = event || window.event;
_eventButtonElement  = evnt.target || evnt.srcElement;
+5
source

This should work: _eventButtonElement = window.event.srcElement || window.event.originalTarget;

originalTarget is the firefox equivalent, equivalent to srcElement.

+2
source

Source: https://habr.com/ru/post/1783163/


All Articles