As we all know, except for the tab line, the element in Firefox does not have the focus concept (you can add the tabindex attribute to the general element to make it focus ). no. Why not do it yourself.
<SCRIPT>
// Just can be running in Firefox Studio
If (document. addeventlistener)
Document. addeventlistener ("click", function (event) {firefoxfocuschange (event) ;}, false );
// The IE Brower does not support the Function
VaR lastfocus = new object; // get a object to pass the script interpreter
VaR currentfocus = NULL; // set the focus for other methods
Function firefoxfocuschange (e ){
VaR E = E | window. event; // compatibility, can be removed, because not to be running in IE Studio
VaR newfocuscmde.tar GET | E. srcelement; // Ditto
If (lastfocus! = Newfocus) {// console. Log ("focuschange ");
If (! Lastfocus. tabindex) {// console. Log ("notabindex"); // check element has property for tabindex to prevent running twice.
If (lastfocus. onblur) {// console. Log ("runblur ");
Lastfocus. onblur ();
}
}
}
If (currentfocus ){
Lastfocus = currentfocus; currentfocus = NULL;} // tested. In ff, the listener event occurs after the onclick method is executed. If the onclick method is used to change the focus, you must add currentfocus to this problem.
Else {
Lastfocus = newfocus ;}
}
</SCRIPT>
The test has passed and the comments are directly written in English. When I practice English and add this self-made script, I can directly fix the onblur problem in Firefox (you can also add the focus event ), in some old projects that can be used, I will encapsulate it and turn it into a module. An onfocus should be exposed (for advanced languages, it is equivalent to inheriting and overwriting ), stop the previous focus setting method on the chained search, so that he will not be allowed to go to the window. onfocus, so that onfocus is normal, do not know whether to give it, so that Firefox is exactly the same as the focus event in IE.
Firefoxfocus creates a focus event for Firefox