jls33fsls
asked on
Disable Backspace in Firefox
I want to disable the backspace button from being used as a back button when the user is not in a textarea or input field. I am using the below code right now, but it only works in IE and has no affect in Firefox.
<script language="javascript">
var inform = false;
document.onkeydown = keyCatcher;
function keyCatcher() {
var e = event.srcElement.tagName;
if (event.keyCode == 8 && e != "input" && e != "textarea") {
event.cancelBubble = true;
event.returnValue = false;
}
}
</script>
<script language="javascript">
var inform = false;
document.onkeydown = keyCatcher;
function keyCatcher() {
var e = event.srcElement.tagName;
if (event.keyCode == 8 && e != "input" && e != "textarea") {
event.cancelBubble = true;
event.returnValue = false;
}
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
is old IE only
w3c compliant browser use event.target, sometimes event.view is also possible
AFAIK cancelBubble is IE proprietary too, but IE as gecko based browser (mozilla, firefox) do not comply to w3c defined standard how to propagate the event up and down the object tree. So be prepared for some ugly hacks if you need that.