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

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

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