PDA

View Full Version : How to scroll-up page when link in a tab clicked



viens
02-19-2007, 12:08 AM
1) Script Title: Ajax Tabs Content script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/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):


<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?

jscheuer1
02-19-2007, 05:00 AM
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:


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:


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:


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
}
}

viens
02-19-2007, 09:48 AM
jscheuer1, tjank you vry much! That's what I was looking for.

masey
03-02-2007, 04:59 PM
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...

jscheuer1
03-02-2007, 07:04 PM
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.

masey
03-02-2007, 07:33 PM
K done.