在 ASP.NET 应用程序中进行 Tab 键切换

发布于 2024-08-21 23:43:08 字数 172 浏览 5 评论 0原文

我开发了一个asp.net应用程序。如果用户通过 Tab 键浏览我的应用程序的字段,然后继续超出末尾,则 Tab 键切换将在我的应用程序之外继续。其中包括用户输入 URL 的框,然后是其他一些框,包括用于输入搜索条件的 Google 框。然后最终它返回到我的应用程序的第一个字段。

如何将选项卡仅限于我的应用程序?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

享受孤独 2024-08-28 23:43:08

处理这个问题最简单的方法就是不这样做。不要改变用户与自己的应用程序交互的方式。这是您无法也不应该控制的事情。 TAB 键具有明确定义的用户界面任务,其工作方式非常可预测。我没有使用过所有可用的浏览器,但我确信在 99% 的浏览器中,Tab 键允许用户在页面上和浏览器工具栏上的输入字段之间进行 Tab 键切换。如果你去改变这一点,你只会让用户感到沮丧。不使用鼠标的用户怎么办?残疾用户怎么办?

请在这里重新考虑您的设计决策。

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.

姜生凉生 2024-08-28 23:43:08

我唯一能想到的是,如果您编写一些 JavaScript 可以捕获页面中最后一个字段上的 onkeydown ,测试它是否为 Tab 键,然后将焦点设置回第一个字段:

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

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文