IE under the onmouseenter and OnMouseLeave to solve.
Unfortunately, FF is not. I think again, why such a good function, why FF do not quote it?
There are IE in the onpropertychange, ah, FF did not ...
A section of JS is introduced in the contrast example to accommodate FF Onmouseenter and OnMouseLeave. :
Copy Code code as follows:
var xb =
{
Evthash: [],
Iegetuniqueid:function (_elem)
{
if (_elem = = window) {return ' Thewindow ';}
else if (_elem = = document) {return ' thedocument ';}
else {return _elem.uniqueid;}
},
Addevent:function (_elem, _evtname, _FN, _usecapture)
{
if (typeof _elem.addeventlistener!= ' undefined ')
{
if (_evtname = = ' MouseEnter ')
{_elem.addeventlistener (' mouseover ', Xb.mouseenter (_FN), _usecapture);}
else if (_evtname = ' MouseLeave ')
{_elem.addeventlistener (' mouseout ', Xb.mouseenter (_FN), _usecapture);}
Else
{_elem.addeventlistener (_evtname, _FN, _usecapture);}
}
else if (typeof _elem.attachevent!= ' undefined ')
{
var key = ' {fnkey::obj_ ' + Xb.iegetuniqueid (_elem) + ':: Evt_ ' + _evtname + ':: Fn_ ' + _fn + '} ';
var f = Xb.evthash[key];
if (typeof F!= ' undefined ')
{return;}
f = function ()
{
_fn.call (_elem);
};
Xb.evthash[key] = f;
_elem.attachevent (' on ' + _evtname, f);
Attach Unload event to the windows to clean up possibly IE memory leaks
Window.attachevent (' OnUnload ', function ()
{
_elem.detachevent (' on ' + _evtname, f);
});
key = null;
f = null; /* DON ' t null this out, or we won ' t is able to detach it * *
}
Else
{_elem[' on ' + _evtname] = _FN;}
},
Removeevent:function (_elem, _evtname, _FN, _usecapture)
{
if (typeof _elem.removeeventlistener!= ' undefined ')
{_elem.removeeventlistener (_evtname, _FN, _usecapture);}
else if (typeof _elem.detachevent!= ' undefined ')
{
var key = ' {fnkey::obj_ ' + Xb.iegetuniqueid (_elem) + ':: evt ' + _evtname + ':: Fn_ ' + _fn + '} ';
var f = Xb.evthash[key];
if (typeof F!= ' undefined ')
{
_elem.detachevent (' on ' + _evtname, f);
Delete Xb.evthash[key];
}
key = null;
f = null; /* DON ' t null this out, or we won ' t is able to detach it * *
}
},
Mouseenter:function (_PFN)
{
return function (_EVT)
{
var reltarget = _evt.relatedtarget;
if (this = = Reltarget | | xb.isachildof (this, reltarget))
{return;}
_pfn.call (this, _evt);
}
},
Isachildof:function (_parent, _child)
{
if (_parent = = _child) {return false};
while (_child && _child!= _parent)
{_child = _child.parentnode;}
return _child = = _parent;
}
};
This article comes from cssrain.cn original link: http://www.cssrain.cn/article.asp?id=952