Home > Web Front-end > JS Tutorial > Solution to focus and blur confusion under IE6_javascript skills

Solution to focus and blur confusion under IE6_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:04:03
Original
1090 people have browsed it
Copy code The code is as follows:



hello
<script> <br>(function(){ <br>var focusTimer = 0; <br>function myBlur(){ <br>document. title= 'blur:' Math.random() ; <br>} <br>function myFocus(){ <br>clearTimeout(focusTimer); <br>focusTimer = setTimeout(function(){ <br>document.title = 'focus:' Math.random() ; <br>},10); <br>} <br>window.onfocus = document.body.onfocusin = myFocus; <br>window.onblur = document.body.onfocusout = myBlur; <br>}()); <br></script>


The general principle is: find many opportunities that may trigger onfocus and onblur, all The onblur is executed immediately, while the onfocus is executed lazily with a delay of 10 milliseconds.
The result is: although myFocus and myBlur are sometimes executed several times more, the correctness of the window status can be guaranteed.
The method may be a bit copycat, but I didn’t think of a better way for the time being, so this can temporarily solve an urgent need.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Why is the focus page not closed?
From 1970-01-01 08:00:00
0
0
0
javascript - Failed to obtain focus under ios
From 1970-01-01 08:00:00
0
0
0
angular.js - ng automatically gets focus
From 1970-01-01 08:00:00
0
0
0
JavaScript focus clearing method
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template