使用onkeypress字符按键兼容所有浏览器

document.onkeypress = function( e ){
	alert( getCharCode( e ) );
};
function getCharCode( e ){
	var e = e || window.event;
	if( typeof e.charCode == "number" ){
		return e.charCode;
	}else{
		return e.keyCode;
	};
};



posted @ 2013-04-23 19:58  javawebsoa  Views(174)  Comments(0Edit  收藏  举报