Bug Tracker

Modify

Ticket #4332 (closed bug: invalid)

Opened 4 years ago

Last modified 2 years ago

window focus event doesn't trigger on IE6

Reported by: segalerez@… Owned by:
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

Example:

$(window).bind('focus',function() {

$.jGrowl('Focus');

});

Works prefectly in Firefox, IE6 behaves in an unexpected manner.

Sometimes it triggers if an input inside gets focus. sometimes not. Sometimes when I switch to the window using Alt+Tab, sometimes not.

Change History

comment:1 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

IE doesn't bubble several form events, including focus. jQuery doesn't control that. For reference, the events supported by .live reliably bubble to window in IE.

 http://docs.jquery.com/Events/live#typefn

comment:2 Changed 4 years ago by segalerez@…

  • Status changed from closed to reopened
  • Resolution invalid deleted

I believe $(window).focus and $(window).blur should have special treatment - in IE using document.onfocusin and document.onfocusout.

See  http://odondo.wordpress.com/2007/08/28/javascript-and-cross-browser-window-focus/

This is also an issue when the window have no form elements at all.

As a cross-browser library, jQuery should suggest a method of detecting when windows get/lose focus, the same way it does for mouseenter and mouseleave.

comment:3 Changed 4 years ago by dmethvin

That enhancement is already on the roadmap for 1.4 and I think there's already a ticket although I can't find it at the moment:

 http://docs.jquery.com/JQuery_1.4_Roadmap

In any case, it won't get lost, and it's working as currently documented. The docs actually specify that focus/blur aren't supported:

 http://docs.jquery.com/Events/live#typefn

comment:4 Changed 4 years ago by brandon

  • Owner brandon deleted
  • Status changed from reopened to new

comment:5 Changed 4 years ago by brandon

I don't believe this bug has anything to do with live as discussed in the comments.

This blog post might shed some light on a possible solution:  http://www.thefutureoftheweb.com/blog/detect-browser-window-focus

comment:6 Changed 3 years ago by dmethvin

  • Status changed from new to open

comment:7 Changed 2 years ago by dmethvin

  • Status changed from open to closed
  • Resolution set to invalid

The focusin event bubbles, but not focus.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.