Ok, I understand your problem better now, try this:

       $(document).focus(function(oEvent) {
               if ( $( oEvent.srcElement || oEvent.target ).ancestors(
"#test" ).length )
                   return true;

               $('#test')[0].focus();

               return false;
       });

Again, with the SVN version of jQuery:
http://jquery.com/src/jquery-svn.js

--John

On 8/15/06, Webunity | Gilles van den Hoven <[EMAIL PROTECTED]> wrote:
> John Resig wrote:
> > Hope this helps. (This is with the SVN version of jQuery)
> >
> Hmm, not really I am trying to do something like this:
> If the event receiving the focus is not a child of another "object", set
> the focus back to that "object".
> As you might guess, this is for a new style lightbox :)
> I am trying to prevent that a user can "tab out" of a lightbox, e.g. to
> a link at the bottom of the page
>
> Here's what i got so far, but it doesn't work yet...
>
> -- Can someone help me?
>
> -------------
> javascript
> -------------
>         $(document).focus(
>             function(oEvent) {
>                 var oElem = oEvent.srcElement || oEvent.target;
>
>                 while (oElem = oElem.parentNode) {
>                     if (oElem == $('#test').get(0)) {
>                         return true;
>                     }
>                 }
>
> // todo: set focus on another element
> $('#test').get(0).focus();
>
>                 return false;
>             }
>         );
>
>
> -------------
> code
> -------------
>     <a href="/1">link 1</a> | <a href="/2">link 2</a> | <a
> href="/3">link 3</a><br />
>     <br />
>
>     <div id="test">
>         <a href="/4">link 4</a> | <a href="/5">link 5</a> | <a
> href="/6">link 6</a>
>     </div>
>
>
> _______________________________________________
> 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