Results 1 to 6 of 6

Thread: How to scroll-up page when link in a tab clicked

  1. #1
    Join Date
    Jan 2007
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default How to scroll-up page when link in a tab clicked

    1) Script Title: Ajax Tabs Content script

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

    3) Describe problem: One of my tabs contains large list of forum messages with page numbers below. When I navigate to another page, it loads in the same tab (I use javascript for this):
    PHP Code:
    <a href=\"javascript:linkjax('messages.php?start=0', 'aca', '$tab')\">1</a> 

    That's perfect so far. The only problem is that when I click on page number and next page loads, I see only bottom part of the content and I have to scrool-up page to see the whole content. Is there any way how to force page to scrool-up automatically when I click on some link inside of tab?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,127
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    It is unclear to me whether, as you say, you need the page to scroll, or perhaps just the content area. Either way, here is where you want to edit the ajaxtabs.js 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
    }
    To scroll the content division to the top:

    Code:
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    {
    document.getElementById(containerid).scrollTop=0;
    document.getElementById(containerid).innerHTML=page_request.responseText
    }
    }
    To scroll the whole page to the top:

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

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

  3. #3
    Join Date
    Jan 2007
    Posts
    23
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1, tjank you vry much! That's what I was looking for.

  4. #4
    Join Date
    Oct 2005
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I'm not sure if my problem is exactly the same as described above, but here's what I'm experiencing.

    My tabbed content is about a half way down the page and beyond the "first fold". When I click on different tabs, the new content loads, but the page always returns to the top forcing you to have to scroll back down to the tabbed content each time. This is annoying to say the least.

    Is there any way of preventing this that people know of?

    Thanks in advance...

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,127
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by masey View Post
    I'm not sure if my problem is exactly the same as described above, but here's what I'm experiencing.

    My tabbed content is about a half way down the page and beyond the "first fold". When I click on different tabs, the new content loads, but the page always returns to the top forcing you to have to scroll back down to the tabbed content each time. This is annoying to say the least.

    Is there any way of preventing this that people know of?

    Thanks in advance...
    I'm not sure if it is the same or not either. How about starting a new thread on this? Provide a link to the problem page as well.
    - John
    ________________________

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

  6. #6
    Join Date
    Oct 2005
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    K done.

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
  •