Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Re: controlling the backspace key


  • From: javascript@xxxxxxxxxx (Bill Marriott)
  • Subject: [Javascript] Re: controlling the backspace key
  • Date: Sun, 24 Nov 2002 20:45:25 +1100

Hi Everyone,

The following code traps the key stroke "backspace" in a web form so that
the user can't navigate back to the last page.
However I would like to engage the function only when the user is not in a
form element.
Does anyone know what code I should use?
Thanks
Bill Marriott

function mykeyhandler() {
  if (window.event && window.event.keyCode == 8) { // try to cancel the
backspace
     window.event.cancelBubble = true;
     window.event.returnValue = false;
     return false;
  }
}

document.onkeydown = mykeyhandler;