How to prevent tab key from causing tabbing to the tool bars in IE and Firefox

Discussion in 'ASP .Net' started by Otis Mukinfus, Jan 14, 2007.

  1. Sorry for the long title.

    How does one prevent a tab key press from causing the focus to leave a page and
    move to the navigation bar and tool bars in a browser?

    I've set the TabIndex on all of the controls on the page, but as soon as I hit
    the tab key the focus jumps to the nav control in IE or Firefox.

    Thanks,
    Good luck with your project,

    Otis Mukinfus
    http://www.arltex.com
    http://www.tomchilders.com
     
    Otis Mukinfus, Jan 14, 2007
    #1
    1. Advertising

  2. Re: How to prevent tab key from causing tabbing to the tool barsin IE and Firefox

    Hi,

    Otis Mukinfus wrote:
    > Sorry for the long title.
    >
    > How does one prevent a tab key press from causing the focus to leave a page and
    > move to the navigation bar and tool bars in a browser?
    >
    > I've set the TabIndex on all of the controls on the page, but as soon as I hit
    > the tab key the focus jumps to the nav control in IE or Firefox.
    >
    > Thanks,
    > Good luck with your project,
    >
    > Otis Mukinfus


    If the first and last "tab-enabled" objects on the page are controls
    (and not links), you can use the following JavaScript (for example):

    (first control on the page)

    <input type="text" id="tfFirst" ... />

    (last control on the page)
    <input type="button"
    onblur="document.getElementById('tfFirst').focus();" ... />

    I looked for something similar for links, but I cannot find anything for
    the moment. Though in theory links also support onblur and focus, I
    can't seem to make it work in IE.

    HTH,
    Laurent
    --
    Laurent Bugnion [MVP ASP.NET]
    Software engineering: http://www.galasoft-LB.ch
    PhotoAlbum: http://www.galasoft-LB.ch/pictures
    Support children in Calcutta: http://www.calcutta-espoir.ch
     
    Laurent Bugnion [MVP], Jan 14, 2007
    #2
    1. Advertising

  3. On Sun, 14 Jan 2007 16:44:56 +0100, "Laurent Bugnion [MVP]"
    <> wrote:

    At bottom...
    >Hi,
    >
    >Otis Mukinfus wrote:
    >> Sorry for the long title.
    >>
    >> How does one prevent a tab key press from causing the focus to leave a page and
    >> move to the navigation bar and tool bars in a browser?
    >>
    >> I've set the TabIndex on all of the controls on the page, but as soon as I hit
    >> the tab key the focus jumps to the nav control in IE or Firefox.
    >>
    >> Thanks,
    >> Good luck with your project,
    >>
    >> Otis Mukinfus

    >
    >If the first and last "tab-enabled" objects on the page are controls
    >(and not links), you can use the following JavaScript (for example):
    >
    >(first control on the page)
    >
    ><input type="text" id="tfFirst" ... />
    >
    >(last control on the page)
    ><input type="button"
    >onblur="document.getElementById('tfFirst').focus();" ... />
    >
    >I looked for something similar for links, but I cannot find anything for
    >the moment. Though in theory links also support onblur and focus, I
    >can't seem to make it work in IE.
    >
    >HTH,
    >Laurent


    Laurent,

    I found the solution: Here is a sample:


    CountryDropDownList.Attributes.Add("onkeydown", "if(event.which ||
    event.keyCode)" +
    "{if ((event.which == 9) || (event.keyCode == 9)) " +
    "{document.getElementById('" + LatitudeTextBox.ClientID +
    "').focus();return false;}} else {return true}; ");

    LatitudeTextBox.Attributes.Add("onkeydown", "if(event.which ||
    event.keyCode)" +
    "{if ((event.which == 9) || (event.keyCode == 9)) " +
    "{document.getElementById('" + LatitudeDropDownList.ClientID +
    "').focus();return false;}} else {return true}; ");


    What it amounts to is hijacking the tab keystroke.

    Thanks for trying to help. I appreciate it!

    Good luck with your project,

    Otis Mukinfus
    http://www.arltex.com
    http://www.tomchilders.com
     
    Otis Mukinfus, Jan 14, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QUNhdW50ZXI=?=

    tabbing and loading tables when textbox key is pressed?!?!

    =?Utf-8?B?QUNhdW50ZXI=?=, Dec 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    341
    William F. Robertson, Jr.
    Dec 6, 2004
  2. UJ
    Replies:
    1
    Views:
    620
    John Timney \(MVP\)
    Nov 1, 2006
  3. Julia B
    Replies:
    7
    Views:
    1,211
    Paolo opg
    Sep 17, 2008
  4. M P
    Replies:
    1
    Views:
    559
  5. HopfZ
    Replies:
    0
    Views:
    312
    HopfZ
    Jan 8, 2007
Loading...

Share This Page