39 users online (0 members and 39 guests)  


  Results 1 to 2 of 2
  1. #1
    huseyin_aktu's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2005
    Posts
    1

    onkeyup and backspace key

    Hi,
    Firstly, I want to say I am new on javascript.
    I want to remove backspace key. I mean that when user presses backspace key, I will prevent user to go back page. But user can press any part of the page, not speficific part. I thought that I can do this operation in body tag. And I wrote this code;
    Code:
    <body onkeyup="blockbackspace(this)">
    And there is a javascript function;
    Code:
    function blockbackspace(n){
          if (event.keyCode == 8){
             ???? 
          }
    }
    As you see above, when user press backpace "if (event.keyCode == 8)" is true. But what should I do rest of this? Altough I wrote this javascript the back page is loaded. How can I prevent?

  2. #2
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316

    Re: onkeyup and backspace key

    It's usually not a good idea to disable features of the browser. Remember that the user can still click on the "Back" button on the menu, or right-click and click on "Back" from the context menu. Do remember that the "Back" button serves a useful function, and that users will usually run away from websites that do such things.

    However, if you still want to disable the backspace key..

    function blockbackspace(n){
    if (event.keyCode == 8){
    return false;
    }
    }



Tags for this Thread