Results 1 to 4 of 4

Thread: Ajax and scroll to top issue

  1. #1
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Ajax and scroll to top issue

    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

    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
    Last edited by jogl; 05-08-2012 at 06:59 PM.

  2. #2
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Does no-one have any ideas? Sorry for the bump!

  3. #3
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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/dynamici...jaxcontent.htm
    Last edited by jscheuer1; 09-23-2012 at 03:59 PM. Reason: merge posts

  4. #4
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    Please encase you code in [code] tags when posting code to the forums.
    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
    Anime Views Forums
    Bernie

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •