是的,我以前也遇到过这样的问题。onKeypress无法处理中文输入。一直没有解决,我想应该是输入法或者操作系统的问题。非js能及也

解决方案 »

  1.   

    As of Microsoft® Internet Explorer 4.0, the onkeypress event fires and can be canceled for the following keys:Letters: a - z 
    Numerals: 0 - 9 
    Symbols: ! @ # $ % ^ & * ( ) _ - + = < > [ ] { } , . / ? \ | ' ` " ~ 
    System: ESCAPE, SPACE, SHIFT 
      

  2.   

    <input type=text onpropertychange="tt.value+='a'">
    <input type=text id=tt>用微软拼音、全拼和智能abc都试过了,可以正常运行。只不过在微软拼音的时候可能会执行多次而已。
    还有一种方法,就是使用onkeydown事件。不过执行的次数就更多了。
      

  3.   

    使用onpropertychange事件,如果其它的属性也变化的话也会调用,这并不是我们希望的。
    比如:
    <input type=text onpropertychange="funtionName()" size=10>
    我们改变value和size的值都会引发onpropertychange事件,但是我们可能只希望value值改变时才允许调用functionName()方法。
    因此,我们可以在functionName()方法中再加入:
    if(event.propertyName=="value"){
    .....
    }
    这样的判断。:)