Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

backspace key disable

843835May 23 2003 — edited Apr 18 2005
this is sort of a javascript question, but its on my jsp pages so i'll ask. ;)

I would like to be able to disable the backspace key so that
a user cannot hit it to travel back a page. However, i want to leave
it enabled so that they can at least backspace while in form text elements and text areas, etc.

i have this bit of code (see bottom) that will capture the backspace, but it turns it off even for the text elements in a form.

the good news is that its for an intranet application and we are only going to be supporting IE 5.5 or better, so it doesn't have to be cross browser compatible

thanks,
ken
<script language="JavaScript"><!--
document.onkeydown = mykeyhandler;
 
function mykeyhandler() {
    if (window.event && window.event.keyCode == 8) {
        // try to cancel the backspace
        window.event.cancelBubble = true;
        window.event.returnValue = false;
        return false;
    }
}
//--></script>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 16 2005
Added on May 23 2003
5 comments
264 views