Rich Bradshaw
Rich Bradshaw

Reputation: 72975

What events are fired on changing tab away and to a page?

I have an image slider that slides automatically. Because I'm nice, I want to ensure that it doesn't continue to slide when the user has a different window/tab focused.

What events fire when leaving a tab/window, and which fire when returning?

Upvotes: 4

Views: 1526

Answers (1)

Lekensteyn
Lekensteyn

Reputation: 66415

When leaving: blur; when entering: focus. Additionally, the following can happen:

  • click when the user clicks on the window to get focus;
  • mouseover when the user moves over the window;
  • mousedown/mouseup (related to clicking);
  • keyup/keydown when pressing a key (e.g. ctrltab).

Upvotes: 3

Related Questions