Advanced Search

Results 1 to 3 of 3

Thread: Divs in place of frames -- scrollbar never resets

  1. #1
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post Divs in place of frames -- scrollbar never resets

    1) Script Title: Dynamic Ajax Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    3) Describe problem: So I'm using this script for my nav to load each section of my site into a "content" div, obviously like a php include. The page was originally all seperate php docs but now that I've added streaming audio I wanted an alternative to having to switch to a frame-based layout. The script works great but if the div is scrolled any % down from the top, when another link in the nav is clicked the div remains at that scroll point. My initial ideas have been with anchors and auto-scrolling javascripts but I can't seem to cook up an approach that works. Perhaps an augmentation to the existing ajax content script? Any ideas out there?

    If seeing the problem in action is necessary I'll post the URL.

    Thanks!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,681
    Thanks
    43
    Thanked 3,126 Times in 3,092 Posts
    Blog Entries
    12

    Default

    Find this section in the script:

    Code:
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=page_request.responseText
    }
    Replace it with:

    Code:
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
    document.getElementById(containerid).innerHTML='<div style="width:2000px;height:2000px;">&nbsp;</div>';
    document.getElementById(containerid).scrollTop = 0;
    document.getElementById(containerid).innerHTML=page_request.responseText;
    }
    }
    Just make sure that the dimensions:

    Code:
    style="width:2000px;height:2000px;"
    are higher than tallest content page you might load and wider than the widest one.
    Last edited by jscheuer1; 07-07-2011 at 08:16 AM. Reason: fix minor typo in code
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    brianfitzy (07-07-2011)

  4. #3
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    John,

    Slick. Working great! I really appreciate the help!

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
  •