HTML:什么决定了“按下 Enter 键时将焦点移至下一个控件”行为

发布于 2024-08-07 19:50:54 字数 779 浏览 2 评论 0原文

一个基本的 HTML 问题。当在文本框中按 Enter 键将焦点移动到下一个控件时,是否可以在 HTML 页面上以声明方式实现某种行为?如何实现它以及如何关闭它?或者也许这里应该涉及动态javascript部分?

例如,IE7 中的以下 HTML 不允许使用 Enter 将焦点移动到下一个文本框:

<html>
<body>
<form>
<table>
<tr><td>
<input type="text" name="i1"/>
<td></tr>
<tr><td>
<input type="text" name="i2"/>
<td></tr>    
</table>
</form>
</body>
</html>

我有一个页面,需要摆脱这种“按下 Enter 时将焦点移动到下一个控件”行为。

@Edit:上面的示例结果是不正确。当我在想要避免这种行为的页面上按 Enter 键时,焦点跳转到的控件实际上是“提交”类型。奇怪的是,这个“提交”是 Telerik 树控件的一部分,并不是提交按钮,而是用于折叠和展开树结构的箭头。 因此,我假设焦点跳转到下一个提交控件,浏览器期望该控件是一个普通的提交按钮,但在我的情况下并非如此。

所以我想我应该在这里寻找 Telerik 的具体解决方案。

A basic HTML question. Is it possible on an HTML page to declaratively achieve a behavior when pressing Enter in a textbox moves the focus to the next control? How do you achieve it and how do you turn it off? Or maybe the dynamic javascript part should be involved here?

For exaple, the following HTML in IE7 does not allow to move to the focus to the next textbox with enter:

<html>
<body>
<form>
<table>
<tr><td>
<input type="text" name="i1"/>
<td></tr>
<tr><td>
<input type="text" name="i2"/>
<td></tr>    
</table>
</form>
</body>
</html>

I have a page where I need to get rid of this 'move the focus to the next control when Enter is pressed' behavior.

@Edit: The example above turns out to be incorrect. The control the focus jumps to when I press enter on the page I want to avoid this behavior on is actually of type submit. The strange thing is that this "submit" is a part of a Telerik tree control and is not a submit button but an arrow used to collapse and expand the tree structure.
So I assume the focus jumps to the next submit control which the Browser expects to be a normal submit button which is not true in my case.

So I suppose I should look for a Telerik pecific solution here.

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

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

发布评论

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

评论(2

深空失忆 2024-08-14 19:50:54

在大多数浏览器中,当焦点位于表单中时按 Enter 键将提交表单。如果您需要更改此行为,以便按 Enter 移动到下一个文本框,您将需要使用 javascript。

试试这个:(由 javascript.internet.com 提供)

http://javascript. internet.com/forms/tab-key-emulation.html

In most browsers, pressing Enter when focused within a form will submit the form. If you need to change this behavior so that pressing Enter moves to the next textbox you will need to use javascript.

Try this: (courtesy of javascript.internet.com)

http://javascript.internet.com/forms/tab-key-emulation.html

泪意 2024-08-14 19:50:54

我通常在以下位置查找这些内容:
http://start.gotapi.com/

<input type="text" name="i1" Tabindex="[order number]"/>

I usually lookup these things on:
http://start.gotapi.com/

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