在Chrome移动浏览器上,keypress/keyup不起作用 [英] keypress/keyup is not working on chrome mobile browser
问题描述
我一直在基于Web的Asp.net MVC应用程序中使用jquery,当我使用chrome mobile测试我的工作时,我发现基于keypress/keyup的jquery功能不起作用.
I have been using jquery in my web based Asp.net MVC application, and when i use chrome mobile to test my work i found that jquery's functions which are based upon keypress/keyup is not working.
我不知道为什么它不能在移动浏览器上运行.它可以在桌面浏览器上正常工作.
I didn't know why it is not working on mobile browsers. It is working properly on desktop browsers.
任何人都可以解决我的问题,在此先感谢.
Can anyone solve my problem, thanks in advance.
推荐答案
这对我有用: http://www. dotnetfunda.com/forums/show/8137/onkeyup-event-not-firing-in-firefox-and-chrome
This worked for me: http://www.dotnetfunda.com/forums/show/8137/onkeyup-event-not-firing-in-firefox-and-chrome
代码:
<textarea name="textarea" id="txtComments" rows="3" onkeyup='return fnMaxLength(this,"5");' style="width: 940px" ></textarea>
函数fnMaxLength(field,maxChars){
function fnMaxLength(field, maxChars) {
if (field.value.length >= maxChars) {
var object = "-More than " + maxChars + " characters have been entered.";
//errorAlert("error", "Maximum length error", object);
alert(object);
return false;
}
}
这篇关于在Chrome移动浏览器上,keypress/keyup不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!