javascript - Why do blur event not working? -
this code have:
var interval; function printpagestate() { console.log("active"); } window.onfocus = function() { console.log("focus"); clearinterval(interval); interval = setinterval(printpagestate, 2000); }; window.onblur = function() { console.log("blur"); clearinterval(interval); }; window.onscroll = function() { console.log("scroll"); if (!document.hasfocus()) document.getelementbyid("some-id").focus(); clearinterval(interval); interval = setinterval(printpagestate, 2000); }; i'm attempting create user attention checker/page-pinging functionality. checker has event handler blur, focus, , scroll event.
and i'm having problem stated above when following stuff met.
- your browser had viewable part on browser view port make possible scroll if page not in focus.
- the page out of focus , or blur event fired.
i want stop interval blur event not firing anymore browser isn't focus tried force focus state on 1 of element no locky wasn't working.
do following issue replicate issue:
- open page in minimized browser > focus out page.
- scroll on visible browser view port not click (which won't make focus state true).
Comments
Post a Comment