简体   繁体   English

在使用JavaScript的文本框中将自动完成功能与FF(或IE)一起使用时,如何禁用快捷键处理?

[英]How to disable keydown processing when using autocomplete with FF (or IE) in a text box using javascript?

In order to control what fields the Enter key affects, I wrote the folowing javascript which gets called on the keydown event: 为了控制Enter键影响哪些字段,我编写了以下javascript,它在keydown事件中被调用:

function editorEnter(e)
{
    var key;
    if (window.event) key = window.event.keyCode;     //IE
    else key = e.which;                               //firefox
    if (key == 13) addEditorRow('EditorTable');
}

Here's how it is used in the context of a text field: 以下是在文本字段的上下文中使用它的方式:

<input type="text" name="EditorSurname" class="EditorSurnameText" 
 value="" onkeydown="editorEnter(event);" onkeyup="EnableSave();"/>

The problem is that in FireFox with autocomplete enabled, if I select a value from the autocomplete dropdown and press enter, it does not perform the autocomplete and adds the row to the table. 问题在于,在启用了自动完成功能的FireFox中,如果我从自动完成功能下拉列表中选择一个值并按Enter,则它不会执行自动完成功能,而是将行添加到表中。 Is there a way to disbale the enter key functionality when selecting autocomplete? 选择自动完成功能时,是否可以取消Enter键功能?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过使用JavaScript与文本框自动完成功能 - AutoComplete functionality with Text Box by using JavaScript 在IE和FF中禁用Google工具栏自动完成功能 - Disable Google Toolbar Autocomplete in IE and FF 在JavaScript中使用单个功能单击其他单选按钮时如何禁用文本框? - How to disable a text-box when clicking on other radio-buttons using a single function in javaScript? 在Javascript中使用类名禁用文本框 - Disable text box using class name in Javascript 无法使用JavaScript禁用文本框 - Unable to disable text box using javascript 使用javascript提交表单,可以在FF中使用,但不能在IE中使用 - Submit form using javascript, work in FF but not in IE 使用jQuery-ui使用php和javascript自动完成文本框 - Using jQuery-ui to autocomplete a text box with php and javascript 使用Javascript XUL触发FF文本框中的按键计数器的自定义警报 - Trigger custom alert for Key press counter in FF text-box using Javascript XUL 使用此javascript,占位符适用于IE / Firefox中的文本但不适用于密码框 - placeholder works for text but not password box in IE/Firefox using this javascript 在 Javascript 上使用 addEventListener 时 keydown 不起作用 - keydown is not working when using addEventListener on Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM