我需要什么事件来阻止IE从“Dinging”当我在文本框中按Enter键? [英] What event do I need to supress to stop IE from "Dinging" when I press enter in a text box?

查看:206
本文介绍了我需要什么事件来阻止IE从“Dinging”当我在文本框中按Enter键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



但是在一个带有多个

的表单上, / strong>字段,在input =text框中按Enter键将不会执行任何操作(例如提交),但在IE中,Dings就像您尝试删除不可删除的对象一样。



问题是...我需要什么事件来抑制IE停止这个声音?例如如果我有一个用户名/密码表单,我想要输入密钥提交表单,但我当然不想要错误的声音。



示例网站声音:
http://www.sears .com / shc / s / StoreLocatorView?storeId = 10153& catalogId = 12605
只需在任意文本字段中按Enter键即可。叮叮叮叮叮叮!D D D D D <>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

解决方案

看来,这样做有效:

 code><! - 抑制声音(并抑制提交) - > 
< input type =textonkeypress =if(window.event.keyCode == 13){return false;}/>

<! - 抑制声音(但允许提交) - >
< input type =textonkeypress =if(window.event.keyCode == 13){this.form.submit(); return false;}/>


On simple forms with one text box pressing enter submits the form (and this is great for easy search forms)

However on a form with multiple fields, pressing Enter in an input="text" box won't do anything (e.g. submit) but in IE it "Dings" as if you have tried to delete an undeletable object.

The question is... what event do I need to suppress in IE to stop this sound? e.g. if I have a username/password form, I DO want the enter key to submit the form, but I certainly don't want the "error" sound.

Example site with the sound: http://www.sears.com/shc/s/StoreLocatorView?storeId=10153&catalogId=12605 Just press Enter in any of the text fields. Ding!, Ding!, Ding!

Non-IE users, the sound is the: Program Events > Windows > Default Beep ("Windows XP Ding.wav")

解决方案

Well it appears that this works:

<!-- 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;}"/>

这篇关于我需要什么事件来阻止IE从“Dinging”当我在文本框中按Enter键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆