Bug Tracker

Opened 15 years ago

Closed 13 years ago

#4332 closed bug (invalid)

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:
Blocked by: Blocking:

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 (7)

comment:1 Changed 15 years ago by dmethvin

Resolution: invalid
Status: newclosed

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 15 years ago by segalerez@…

Resolution: invalid
Status: closedreopened

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 15 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 14 years ago by brandon

Owner: brandon deleted
Status: reopenednew

comment:5 Changed 14 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 13 years ago by dmethvin

Status: newopen

comment:7 Changed 13 years ago by dmethvin

Resolution: invalid
Status: openclosed

The focusin event bubbles, but not focus.

Note: See TracTickets for help on using tickets.