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
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.
If I understand you correctly, you can use this:
window.addEventListener("blur",function(){
//mystuff
},false);
and this:
window.addEventListener("focus",function(){
//mystuff
},false);