javascript - onblur event not fired every time -


the onblur event not firing.

it's not predictable. included small program can run replicate problem. need click inside iframe , see if in consol there's asti. if it's there, alright world. sometimes, however, onblur doesn't fire , nothing printed. failure frequency 5%.

why onblur event not fire?

<html>   <head>       <title> index </title>   </head>   <body >     <h1> tabarnac </h1>     <p>chikanuti</p>     <iframe src=""></iframe>   </body>     <script type="text/javascript">     var body = document.getelementsbytagname("body")[0];     document.activeelement.blur();     window.focus();     body.onblur=function(){         console.log("asti");     };     </script> </html> 

the onblur event fires when leave element (the element loses focus). so, when click iframe, body loses focus , event fires. if click out of iframe, , click iframe again, event fire again.

demo: http://jsfiddle.net/42tbd4fb/


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -