什么事件,我需要剿从“卧底”停即当我按在文本框中输入?
-
11-09-2019 - |
题
在与一个文本框中输入按压简单的形式提交表单(这便于搜索表单大)
不过是多个字段,在输入按Enter键=形式的“文本”框中不会做任何事情(如提交),但在IE中“丁氏家族”,如果你试图删除不可删除的对象。
现在的问题是...我需要在IE压制停止这种声音是什么事件?例如如果我有一个用户名/密码的形式,我想回车键提交表单,但我肯定不希望“错误”的声音。
实施例的网站与声音: http://www.sears.com/shc/s/StoreLocatorView?storeId = 10153&采用catalogId = 12605 只需按Enter键在任何文本字段。丁丁!丁!!
非IE用户,声音是:程序事件>视窗>默认蜂鸣( “Windows XP中Ding.wav”)
解决方案
那么看来这个作品:
<!-- suppress sound (and suppress submit) -->
<input type="text" onkeypress="if(window.event.keyCode == 13){return false;}"/>
<!-- suppress sound (BUT allow submit) -->
<input type="text" onkeypress="if(window.event.keyCode == 13){this.form.submit();return false;}"/>
其他提示
$("#logonForm").keypress(function (e) {
if (e.keyCode == '13') {
if (instance.Validate(instance)) {
document.forms["logonForm"].submit();
return false; //Do not delete, suppresses ding in IE... :P
}
}
});
这工作的,我们使用它。
他是正确的。你想要的文本字段,不要与丁松惹恼你
仅添加
onkeypress="if(window.event.keyCode == 13){return false;}"
要你输入标签
<input type="whatever" onkeypress="if(window.event.keyCode == 13){return false;}" >
不过,不这样做在提交或按钮输入OK。只有到了文本字段,这样你就不会获得由丁恼火!丁!现在。 余检查。
$("#txtSomething").keypress(function (e) {
if (e.which == 13) {
e.Handled = true; //This will prevent the "ding" sound
//Write the rest of your code
}
});
我想这是由OS&因此控制,它不能使用JavaScript来控制。
不隶属于 StackOverflow