Christian
Christian

Reputation: 3393

Firefox extension: window activate/deactive event

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 basically work. But noticed that when I move the window, first "deactivate" (when I start moving) and then "activate" (when I finished moving through releasing the mouse key) occurs. For me, the whole time the window is active.

What is the best / simplest way to the "deactivate"/"activate" event pair when moving the Firefox window? Thanks a lot for any tips!

Christian

Upvotes: 0

Views: 1157

Answers (2)

Liran
Liran

Reputation: 611

If I understand you correctly, you can use this:

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

and this:

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

Upvotes: 1

Christian
Christian

Reputation: 3393

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.

Upvotes: 0

Related Questions