PDA

View Full Version : Ajax and scroll to top issue



jogl
05-08-2012, 12:00 PM
Hi guys,

I'm building a portfolio site for myself and not being a very good programmer i've stumbled across an issue I hope someone can help with!

Here's the link - link (http://www.joegoodall.co.uk)

The way it works on the gallery page is - gallery items are loaded into 'galleryblock0' using ajax. Then when you click on a gallery item, i'm using ajax to replace the content in the galleryblock0 div. (this is so the page doesn't have to reload every time)

The problem i'm having is when you scroll down the gallery page, it remembers the vertical position instead of loading at the top of the page. I've tried so many options (some from this forum) but i'm stumped.

My jump to top buttons are working fine (href="javascript:scroll(0,0)"). I just need it to do that automatically on load of the page.

THANKS in advance if anyone can help. Hope i've given enough information.
Joe

jogl
05-09-2012, 10:33 AM
Does no-one have any ideas? Sorry for the bump!

amandag
09-23-2012, 03:34 PM
this worked for me:

window.scrollTo(0,0);
document.getElementById(containerid).innerHTML=page_request.responseText;

I added the code in red

assuming you are using this example: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

bernie1227
09-24-2012, 06:38 AM
Please encase you code in [code] tags when posting code to the forums.