0

window.onfocus is not getting fired when the focus is on a child iframe.

I'm looking for an event which will be fired when the user is switching the tab to current page. (If possible without modifying child iframes)

j0k
  • 22,600
  • 28
  • 79
  • 90
Chakradar Raju
  • 2,691
  • 2
  • 26
  • 42
  • 2
    @RaulGogo [The question title shouldn't contain any tags](http://meta.stackexchange.com/a/130208/206447). – Bernhard Barker Feb 11 '13 at 08:29
  • blur event should be what you're after – Tivie Feb 11 '13 at 08:33
  • @Tivie: I don't understand how blur can be useful for that. Can you please explain? – Chakradar Raju Feb 11 '13 at 08:36
  • @Dukeling: I should be ashamed of not knowing that. My bad. Thank you for pointing it out. – Raul Rene Feb 11 '13 at 08:38
  • focus event is when an element is gaining focus, blur is when an element is loosing focus. You asked for an event that will be fired when the user is switching. That event is blur – Tivie Feb 11 '13 at 08:39
  • see this: http://stackoverflow.com/questions/5456239/detecting-when-an-iframe-gets-or-loses-focus – Tivie Feb 11 '13 at 09:00
  • and this: http://stackoverflow.com/questions/369026/setting-focus-to-iframe-contents – Tivie Feb 11 '13 at 09:01
  • and this one which links to a post outside SO http://stackoverflow.com/questions/1926861/iframe-onblur-event – Tivie Feb 11 '13 at 09:01
  • @Tivie: I want to know when the user switches to the tab where my app is open, he might have switched from a tab with facebook, gmail, etc. It could be anything, I can't track onblur of other sites. – Chakradar Raju Feb 11 '13 at 09:03
  • AH, you mean actual browser tabs, not the TAB key. My mistake. – Tivie Feb 11 '13 at 09:04
  • even so, the links I posted are relevant. Is your iframe and your main page on the same domain? – Tivie Feb 11 '13 at 09:08

0 Answers0