User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » on page load, scroll to bottom Page [1]  
Novicane
All American
15413 Posts
user info
edit post

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

Golovko
All American
27023 Posts
user info
edit post

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

Novicane
All American
15413 Posts
user info
edit post

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

Golovko
All American
27023 Posts
user info
edit post

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 element

position() = 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

Novicane
All American
15413 Posts
user info
edit post

cool, i'll try that

10/26/2009 4:34:56 PM

Golovko
All American
27023 Posts
user info
edit post

np...if you aren't familiar with jQuery just post any issues here

10/26/2009 4:35:45 PM

 Message Boards » Tech Talk » on page load, scroll to bottom Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.