PDA

View Full Version : Dynamic Ajax Content overflow reset (scrollTop)



monkeytribe
12-07-2007, 03:14 PM
1) Script Title:
Dynamic Ajax Content

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

3) Describe problem:

Great wee script, but i am having problems getting each page content to load at the top of the div if the scroll bar has been scrolled down...

To be more concise, the scroll state of the container is being preserved when new content is loaded, but i don't want the scroll state to be preserved. I want the content to be loaded at the top of the div.

see the problem in action here:

http://www.monkeytribe.net/index2.php

works fine until you scroll down; then the scroll position is preserved for the next content loaded. How to reset the scrollTop?

i have tried the fix explained here:
http://www.dynamicdrive.com/forums/archive/index.php/t-11508.html
but with no luck, the code suggested is still on the "discog" link in the footer, but seems to have no effect...

i have also experimented with good old fashioned #anchor hrefs, but the javascript does not pass the "#anchor" in "xxx.php#anchor" as discussed here:
http://www.dynamicdrive.com/forums/showthread.php?t=20830

any ideas or fixes will be greatly appreciated!

ddadmin
12-08-2007, 01:08 AM
Are you talking about in a particular browser here? I just tested your page in FF2 and IE7, and everything seems to work correctly. I tried loading a content that generates scrollbars, scrolled down, then clicked on another link. Either the scrollbar disappears if the content doesn't need it, or if the content needs it, it loads with the scrollbar position back at the very top.

jscheuer1
12-08-2007, 05:08 AM
I've answered you in that thread:

http://www.dynamicdrive.com/forums/showthread.php?t=11508

If you need more help with that solution, continue in that thread.

Anchor links for page scrolling will not generally work in Ajax until after the content has loaded and the page has stabilized with its new code, and only then if they would work on a normal page under the same circumstances and with the same code as the page then has on it.