i have a page that has a div inside of it. This div usually grows in size and the onChange function is used to create new items. It may get very long, so on each reload is scrolls back up to the top.I've tried a few JS functions in the onchange of a drop box but no luck. I rather just have the div scroll down to the bottom each time it reloads instead of waiting on a onchange event to happen.
10/26/2009 4:04:57 PM
I'm so confused. Let me try and better understand what you are trying to do.You have a div with overflow:auto/scroll?Your page doesn't scroll but the div does or does your page also have a scroll bar?You want whatever updated 'new' element to be visible in the div by scrolling to it?There are several ways to do this very easily especially with jQuery.
10/26/2009 4:13:00 PM
as the div grows, the page starts to auto scroll, because the user is adding items.My page has the scroll bar, the div does not. The div sort of blends in with the page. Basically the new element every time the div is reloaded will be on the bottom of the page and div. So on each div reload, it needs to jump to the bottom of either the div or the page.[Edited on October 26, 2009 at 4:25 PM. Reason : d]
10/26/2009 4:24:08 PM
ok...that makes sense now.just use jQuery.var position = jQuery('#newElement').position();window.scrollTo(0, position.top);newElement = the id you give the new elementposition() = returns the top and left position of the element. Since you aren't side scrolling you can just set the x to 0 for scrollTo(x,y)if you want to get fancy you can animate the scroll (which i think is cleaner) so the user doesn't get lost when the page suddenly jumps to something else...they will at least visually see that the page is being scrolled.[Edited on October 26, 2009 at 4:34 PM. Reason : .]
10/26/2009 4:32:12 PM
cool, i'll try that
10/26/2009 4:34:56 PM
np...if you aren't familiar with jQuery just post any issues here
10/26/2009 4:35:45 PM