The problem has more to do with the fact that you're doing two things wrong:
1) You're setting focus to a <div> element... which is unfocusable.
2) You're setting focus to the element before you ever finish the
focus function of the previous element - creating an infinite loop.

However, the following code seems to work relatively well:
                $(document).focus(
                        function(oEvent) {
                                if ($(oEvent.srcElement ||
oEvent.target).ancestors("#test").length)
                                        return true;

                                setTimeout(function(){
                                        $('#link4')[0].focus();
                                }, 13);
                                return false;
                        }
                );

Just putting the focus in a timeout does the trick - and setting the
focus to a link, not the div, works better.

--John

On 8/15/06, Webunity | Gilles van den Hoven <[EMAIL PROTECTED]> wrote:
> John Resig wrote:
> > Ok, I understand your problem better now, try this:
> >
> Thanx for the ultrashort code, however it doesn't work with rev.206
>
> I've set up a test page at:
> http://www.webunity.nl/_test/jquery/focus.html
>
> I got the original idea from this page, but that code is crap :)
> http://www.hedgerwow.com/360/dhtml/yui-dialog/demo.html
>
> -- Gilles
>
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>


-- 
John Resig
http://ejohn.org/
[EMAIL PROTECTED]

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to