disable spacebar pagedown in IE ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eben12
    New Member
    • Dec 2007
    • 1

    disable spacebar pagedown in IE ?

    Hi guys!

    I'm currently building web application that make use of the spacebar and I need to disable the automatic pagedown that is taking place when pressing the spacebar. In Firefox, I use the following javascript on pageload

    Code:
    window.onkeydown=function(e){ 
        if(e.keyCode==32){ 
               return false; 
         } 
    };
    Obviously, it doesn't work in IE....anybody with a solution?

    Thanks!
    Ben.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    IE uses a global event object and has no stopPropagation ... so the following might help :)

    [CODE=javascript]
    window.onkeydow n = function(e) {
    var evt = typeof window.event != 'undefined' ? window.event : e;

    if (evt.keyCode == 32) {
    if (evt.stopPropag ation) {
    evt.stopPropaga tion();
    } else {
    evt.cancleBubbl e = true;
    evt.returnValue = false;
    }
    }
    }
    [/CODE]
    kind regards

    Comment

    Working...