This is an old known bug. The problem is that Firefox does not use event.fromElement
(nor .toElement
) and the others don’t use event.relatedTarget
that Firefox uses... so you have to detect this Feature and adapt the code and compare if the event.relatedTarget
and the event.target
are the same. You can take a look at the jQuery source code.
You could use a function like this to fix that:
function fix(event) {
if (event.type == 'mouseenter') {
event.fromElement = event.relatedTarget;
}
if (event.type == 'mouseleave') {
event.toElement = event.relatedTarget;
}
}
But seeing that you have !src.contains(event.fromElement)
I assume you want this behavior only in mouseenter
of src
(that is to say src
does not contain the element where the mouse came from), so I think you should really use the onmouseenter=""
and if you want to replace, using the onmouseleave
. Something like this: http://jsfiddle.net/far4q1ja/
But the sensible thing would be to use CSS for mousehover purposes... if you can go that way and give CSS classes to those elements so you can write rules in the CSS file.
PS: The mistake you mentioned ReferenceError: event is not defined scripts.js:8:8
is why you’re wearing event
inside the function without having passed an argument with that name. So you have to define the function with that parameter:
function mOvr(src, clrOver, event) {
and then in inline use onmouseover="mOvr(this,'#A8A8A8', event);"
.
Which firefox specific version? in the error console appears any message?
– rray
version 35.0.1 and appears Referenceerror: Event is not defined scripts.js:8:8 on console.
– jp_almeida