Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
11-02-2006, 05:30 PM #1
- Join Date
- Sep 2002
- Cary, North Carolina, USA
- Thanked 0 Times in 0 Posts
suppress DIV scrolling on keydown
I've written my own list object using a DIV with overflow:auto and a table containing the list items. On up/down arrow I move the highlight focus through the list items. Since the scrollbar automagically captures up/down arrow and does its own thing, I've done event.returnValue = false so the scroll bar doesn't get the event and my stuff works well. This is fine in IE, but in firefox I can't get the same to occur. I've tried all the incantations I know for cross browser event cancellation using the function below to no avail. I cannot get firefox to behave the same as IE. Firefox DIV scroll bars
still capture up/down arrow and scroll the DIV.
if (undefined == e) e = window.event;
e.cancelBubble = true;
e.returnValue = false ;
if (undefined != e.stopPropagation) e.stopPropagation();
What my code does is to scroll the DIV only if the highlight focus is moved outside the visible part of the DIV, the way a real list works.Wayne Christian
11-02-2006, 06:04 PM #2
- Join Date
- Oct 2003
- on a ship
- Thanked 6 Times in 5 Posts
try setting an event handler on the body itself
and inside that detects if the div has focus or not, if it does then return false.
i would also recommend using onkeydown, as the window's scroll may be triggered by onkeydown, and if you use onkey up, it would not cancel out the onkeydown event of the window.
Last edited by brandonH; 11-02-2006 at 07:29 PM. Reason: typoI make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.