The following is the code to disable backspace keyboard event for browser back button only. Code works fine for IE, FF, Chrome
jQuery(document).unbind('keypress'); //for other jQuery(document).unbind('keydown'); // for IE jQuery(document).keypress(function (e) { //alert(e.target.nodeName.toUpperCase()); if ( e.target.nodeName.toUpperCase() != 'INPUT' && e.target.nodeName.toUpperCase() != 'TEXTAREA') { var code = (e.keyCode ? e.keyCode : e.which); if ( code == 8 ) return false; } }); jQuery(document).keydown(function (e) { //alert(e.target.nodeName.toUpperCase()); if ( e.target.nodeName.toUpperCase() != 'INPUT' && e.target.nodeName.toUpperCase() != 'TEXTAREA') { var code = (e.keyCode ? e.keyCode : e.which); if ( code == 8 ) return false; } });
No comments:
Post a Comment