|
|
Forum moderator: bigblog |
uCoz Community For Webmasters Design Customization AJAX pagination problem. |
AJAX pagination problem. |
When the page is changed through AJAX pagination it won't go to the top.
http://madgoat-studio.com/blog/ Press the page 2 (or any page), after the page 2 loads it will not start from the top. How can I make it start from the top on page change? |
as Sunny said, ajax allow you to refresh only a part of the website in order to save time and bandwidth, but you can customize it to go to the top of the website on each page clicked, how ?
Use the scrollto() method : Code window.scrollTo(x-coord, y-coord); to go to the top just set x-coord and y-coord to 0 like this : Code window.scrollTo(0,0); you need to edit your script and add it in the "Onclick" parameter, here's an example of the page 2 link how to look like after editing : this is the original : ( does not go to the top) Code <a class="swchItem" href="/blog?page2" onclick="spages('2',this);return false;"><span>2</span></a> edited one (goes to the top on each page) Code <a class="swchItem" href="/blog?page2" onclick="window.scrollTo(0,0);spages('2',this);return false;"><span>2</span></a> A person who never made a mistake never tried anything new
Post edited by steven4u - Thursday, 2015-12-03, 6:55 PM
|
| |||
| |||