PDA

View Full Version : Stop firing backspace event on IE 8



tangalla
4 Mar 2013, 9:53 AM
Hi,
sometimes I press 'backspace', the browser goes backward

Ext.EventManager.on(Ext.isIE ? document : window, 'keypress', function(e){
if (e.getKey() == e.BACKSPACE && (!/^input$/i.test(t.tagName) || t.disabled || t.readOnly)) {
// e.stopEvent();
// })


This code works fine on firefox but the problem is on IE 8 .When I hit backspace button on key board the browser will refresh. I have to stop this event firing on the page

I have refered this http://www.sencha.com/forum/archive/index.php/t-111936.html but it didnt help me
Thanks in advance.

mitchellsimoens
6 Mar 2013, 7:44 AM
Haven't tested but a quick google search says this may work:


if (e.keyCode == 8) {
window.event.keyCode = 0;
}

Another suggestion is:


if (event.preventDefault()) { //Chrome, FF, Safari
event.preventDefault();
} else { //IE
event.returnValue = false;
}