Results 1 to 7 of 7

Thread: Ajax Pagination script

  1. #1
    Join Date
    Mar 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Ajax Pagination script

    1) Script Title: Ajax Pagination script v1.2.2

    2) Script URL (on DD):

    http://www.dynamicdrive.com/dynamici.../ajaxpaginate/

    3) Describe problem:I use this script with very long texts which requires me to scroll down in order to get to the bottom of the page.
    Is there any way to make the script scroll back to the top of the page every time I click the links at bottom navigation?
    Thanks in advance.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Find this in the ajaxpagination.js file:

    Code:
    ajaxpageclass.loadpage=function(page_request, divId){
    	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
    		document.getElementById(divId).innerHTML=page_request.responseText
    	}
    }
    Using a plain text editor like NotePad, change it to:

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

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

  3. #3
    Join Date
    Mar 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thank you john,I changed the code,unfortunately there's still no change.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Possibly reversing the order may work:

    Code:
    ajaxpageclass.loadpage=function(page_request, divId){
    	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
    		var t = document.getElementById(divId);
    		if(t.scrollTop){
    			t.scrollTop = 0;
    		}
    		if(t.scrollTo){
    			t.scrollTo(0, 0);
    		}
    		t.innerHTML=page_request.responseText;
    	}
    };
    However, it's also possible it already worked and you were simply viewing an old cached version, or that you didn't actually make the change to the page you then later tested on, or that there is something peculiar about your layout and/or setup that is preventing this from working, or I may not have understood the situation.

    Bottom line, since this didn't work for you, if the above code and/or information doesn't lead you to a solution, all I can do without seeing the page is guess. That's too time consuming.

    So, if you want more help:

    Please post a link to a page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

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

  5. #5
    Join Date
    Mar 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Here's a link to the page which uses the ajax pagination script:
    http://www.animequotes.net/aq/Meaningful.php

    I transfered the page with the ajax pagination script to a specific folder because it's not ready yet and I can't replace the original one before I finish.

    Now about the problem,when you click "2" or "next" for example, the text field will change to page number 2 but you will still remain at the end of the page and you will have to scroll up manually in order to read page 2 from the beginning.
    I wanted to know if there is a way that you won't have to scroll up by yourself every time you choose a page.

    By the way the page that I sent you the link to is using the second Ajax code you sent me.

    Thanks

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I misunderstood the problem. I thought you meant the scroll state of the quote container. Now I think you mean the scroll state of the window. If so, this will do it:

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

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

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

    bartejer (03-30-2010)

  8. #7
    Join Date
    Mar 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    IT WORKS! Thank you so much!

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
  •