Forum Moderators: open

Message Too Old, No Replies

Disable Arrow Keys Scrolling Page

Disable Arrow Keys Scrolling Page

         

trevordixon

9:34 pm on Jul 6, 2006 (gmt 0)

10+ Year Member



How can I make it so that when the up and down arrows are pressed, my page doesn't scroll? I noticed that in IE when an absolutely positioned div has focus, the page doesn't scroll, but the same is not true in Firefox. I tried giving the focus to a hidden IFrame, but that hasn't helped.

Does anybody have any wisdom for me? Thanks!

Trevor

Demaestro

9:55 pm on Jul 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can't really do this. modern Browsers don't really allow a website to "highjack" keypresses.

That type of allowence by a browser is the stuff vulnerbilities stem from and so they have been removed.

trevordixon

10:16 pm on Jul 6, 2006 (gmt 0)

10+ Year Member



I'm not interested in 'hijacking' the keydown event, I just want something to trick the browser into maybe trying the scroll something besides the document.

I just got the effect I wanted by putting a "hidden" textbox in the page and then giving that textbox the focus. Can anybody forsee problems that might arise from this? It works in Firefox and IE.

Trevor

Demaestro

10:46 pm on Jul 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That is acutally a decent solution. I am having a hard time invisioning a use-case where this won't 'peeve off' the end user but I trust you have good reasons. The only downside I can possibly think of is just frustrating someone who is hitting the down arrow and is expecting something to happen and it doesn't. Although again I don't know your use-case so it is tough to say that.

Sorry I misunderstood your post I re-read it and you hinted at going that route rather then highjaking keystroke events, sorry I thought that was where you were going.

The only thing I would do now if I were you is try it on a Mac in FF. If that works then why not.