The IE6bug detected by Miller is as follows: When you click textarea, The blur of the window is triggered, resulting in confusion between the focus and blur pairs.
The Code is as follows:
Hello
Script
Window. onblur = function (){
Document. title = 'blur: '+ Math. random ();
}
Window. onfocus = function (){
Document. title = 'focus: '+ Math. random ();
}
Script
This should be a very common requirement. For example, the current window regularly updates data, while the window de-focus reduces the information update frequency. The pairing disorder caused by the IE6 bug will disrupt our plans.
I did not find any official instructions or recommended solutions for this bug on the Internet, so I had to develop a solution.
The Code is as follows:
The Code is as follows:
Hello
Script
(Function (){
Var focusTimer = 0;
Function myBlur (){
Document. title = 'blur: '+ Math. random ();
}
Function myFocus (){
ClearTimeout (focustout );
Focustout = setTimeout (function (){
Document. title = 'focus: '+ Math. random ();
}, 10 );
}
Window. onfocus = document. body. onfocusin = myFocus;
Window. onblur = document. body. onfocusout = myBlur;
}());
Script
The principle is: find many opportunities that may trigger onfocus and onblur. All onblur will be executed immediately, while onfocus will be executed with a delay of 10 milliseconds.
The result is: although the myFocus and myBlur are executed several times, the window status is correct.
The method may be a little shanzhai, but I didn't expect a better solution at the moment, which can solve the pressing problem for the moment.