11
25
2008
0

[javascript]IE,火狐兼容捕捉按键事件

按键兼容 

<script type="text/javascript">   
document.onkeydown=kp;   
function kp(e){
    if(!e)var e=window.event;
    var kc=e.which||e.keyCode;
        switch(kc){   
            case 13: alert('carriage return'); break;   
            case 27: self.opener=null;self.close(); break;   
        }
}
</script>
Category: JavaScript | Tags: javascript onkeypress | Read Count: 2211

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com