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.
Comments
Post a Comment