0

Hello all,

I am messing around with the jPaginate files, essentially a pagination script using jQuery. I have the mark up working, but I am just messing around (not a real expert in JavaScript) and I have a simple question. When the user clicks on the next page icon, the next page does indeed load. However I would like the page to load and for the browser to scroll back to the top of the new page. Is there a way to do this in HTML / Javascript?

Many thanks in advance, just wanted to see if there are ways to do this, I have code if anyone needs to see that but I think my problem exists purely because of my lack of understanding of some web design tricks.

Atticusr5

1
Contributor
2
Replies
3
Views
5 Years
Discussion Span
Last Post by atticusr5
0

Here is the piece that is actually driving the change in page:

<script type="text/javascript" src="jquery-1.3.2.js"></script>
		<script src="jquery.paginate.js" type="text/javascript"></script>
		<script type="text/javascript">
		$(function() {
			$("#demo5").paginate({
				count 		: 6,
				start 		: 1,
				display     : 5,
				border					: true,
				border_color			: '#fff',
				text_color  			: '#fff',
				background_color    	: '#c62606',	
				border_hover_color		: '#ccc',
				text_hover_color  		: '#000',
				background_hover_color	: '#fff', 
				images					: false,
				mouse					: 'press',
				onChange     			: function(page){
											$('._current','#paginationdemo').removeClass('_current').hide();
											$('#p'+page).addClass('_current').show();
										  }
			});
		});
		</script>
0

So the fix was pretty simple, inside the 'onChange' function, i just added:

$('body').scrollTop(0);

And bingo it works!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.