Firefox extension: window activate/deactive event

前端 未结 2 1504
予麋鹿
予麋鹿 2021-01-28 03:38

in my Firefox extension I try to handle the event when the browser window is activated or deactivated. Adding the events \"activate\" and \"deactivate\" to the window does basic

相关标签:
2条回答
  • 2021-01-28 04:36

    I finally decided to user timer-based solution: I don't handle DEACTIVE events at once, but only if there weren't any ACTIVATE events after, say ten, seconds. So only after ten seconds I consider a window as deactivated. Resizing/Moving is typically done in way less than 10 seconds. No the optimal solution, of course, but serves my purpose sufficiently.

    0 讨论(0)
  • 2021-01-28 04:39

    If I understand you correctly, you can use this:

    window.addEventListener("blur",function(){
     //mystuff
     },false);
    

    and this:

        window.addEventListener("focus",function(){
        //mystuff
        },false);
    
    0 讨论(0)
提交回复
热议问题