views:

42

answers:

2

I have developed an asp.net application. If the user tabs through the fields of my application and then continues beyond the end, the tabbing continues outside my application. This includes the box where the user enters the URL, then some others including the Google box to enter search criteria. Then eventually it returns back to the first field of my application.

How do I limit the tabbing to my application only?

+1  A: 

The only thing that I can think of is if you wrote some javascript that could catch the onkeydown on the last field within your page, test for it being the tab key, and then set the focus back to the first field:

<body>
    <input id="field1" /><br />
    <input id="field2" /><br />
    <input id="field3" onkeydown="return loopBack();" />
</body>

<script type="text/JavaScript">
    function loopBack() {
        if (event.keyCode == 9) {
            var field1 = document.getElementById("field1");
            field1.focus();
            field1.select();
            return false;
        }
    }
</script>
CAbbott
Grrr... I wanted to flag this down, but changed my mind, since technically this would probably work and answers the original question. Just, please don't do it. :|
Bryan
@Bryan: I agree that it's something *I* probably wouldn't do, but I don't see it as "malicious".
CAbbott
+3  A: 

The easiest way to handle this is to NOT do it. Do not change the way a user interfaces with their own applications. This is something you do not and should not have control of. The TAB key has a well-defined user interface task that works in a very predictable manner. I haven't used every browser available, but I am quite sure that in 99% of them, the tab key allows the user to tab between input fields on a page and on the browser's toolbar. If you go and change this you're only going to frustrate users. What about users who don't use a mouse? What about disabled users?

Please, re-think your design decision here.

Bryan
+1. As someone who regularly uses TAB to navigate around the browser, this would make me hate using the poster's application.
Jim Schubert