1

I've integrated a pagination script to break up long text on a page using jPagination: http://web.enavu.com/js/jquery/jpaginate-jquery-pagination-system-plugin/

See an example here: http://harrisstern.com/who/beachcomberbackstory.html

I'm looking for a way to modify the code to move the focus of a page to the top with each page 'turn' (e.g. moving from 1 to 2, 2 to 3, etc).

I'm a javascript newbie, would appreciate any insight you can offer!

Thanks, Tim Philadelphia, PA

Tim Peterson
  • 13
  • 1
  • 2

2 Answers2

1

I have been working on this for a while now.

Place this line of code in the jPaginate.js file.

$('html, body').animate({scrollTop:0}, 'slow');

It needs to go after

createPagination($(this).attr("title"));

on line 183

and after

createPagination(newcurr);

on lines 192 and 201

These lines are in the "// handle click on pagination" section. This tells each button to scroll to the top of the page, it also has a slight animation making it looks really nice.

Hope this helps.

BostonBB
  • 2,655
  • 3
  • 16
  • 12
  • +1, just for everyone who wants to avoid **scrolling** and wants **jumping** to top after page turn with jpaginate. Replace BostonBB'ss line with `$('html, body').scrollTop(0);` – zk_mars Dec 08 '13 at 21:44
0

Use the scroll function

window.scroll(0, 0);

Here's a fiddle

Adam Rackis
  • 82,527
  • 56
  • 270
  • 393