Guardian-Mage Posted August 9, 2008 Share Posted August 9, 2008 I have a div with overflow:scroll, and inside that div is a table with about 700 rows. The div height is only 350px. I have it set up so when I press the down button, it will scroll through the rows (like an email program). However, in IE the down button scrolls so fast, the row I have selected is out of view, and in firefox, the down button doesn't scroll fast enough. The easiest solution in my mind is to prevent the down button from scrolling unless the selected row is at the bottom of the viewable area, again like an email program (thinking thunderbird). I can probably figure out everything else, but I don't know how to prevent the down button from scrolling my div. Any ideas? Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 11, 2008 Share Posted August 11, 2008 Try this in your div tag: onkeydown="if (event.keyCode==40 || event.keyCode==38) this.blur()" 38 is up and 40 is down. Quote Link to comment Share on other sites More sharing options...
Guardian-Mage Posted August 12, 2008 Author Share Posted August 12, 2008 Thanks, but it didn't work. I believe blur is only for form elements Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 12, 2008 Share Posted August 12, 2008 I just tested it and it does exactly what you asked in IE, but in Firefox nothing happens. Apparently the onkeydown event won't fire on a div in FireFox. I tried to get around this by setting a dummy variable to tell if the div had focus and then execute the condition after a key was pressed only if the div had focus, but I can't get any function to be recognized through an event on the body tag. If you can figure that part out it will work, but I give up on Firefox. I don't understand why everyone thinks it is so much better than IE when it doesn't even recognize the standards. Quote Link to comment Share on other sites More sharing options...
Guardian-Mage Posted August 12, 2008 Author Share Posted August 12, 2008 I primarily use Firefox, but I need my code to work on FF, IE, Safari, and Opera. FF adheres to most standards, but like ALL browsers, it strays from them at times. The reason most people prefer it is because of addons and themes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.