回车提交onkeydown和onkeypress事件

1.onkeydown在ie6中捕捉不到回车事件,用onkeypress代替

 

2.例子

<input  type="password"  onkeypress="f(event)"/>

 

function f(event ){

event = event?event:window.event;
var key = event.keyCode?event.keyCode:event.which;
     if(key==13){
            
     }

}

 

function f(){

     var event = arguments[0]||window.event;
     var key= event.charCode||event.keyCode;
     if(key==13){


     }

}

 

 

你可能感兴趣的:(function,IE,input)