Link to home
Start Free TrialLog in
Avatar of john_yourspace

asked on

Infinite Scroll Back Button

Hi guys,

I am using infinite scroll like this

			  loading: {
						finished: undefined,
						finishedMsg: "<em>Congratulations, you've reached the end of the internet.</em>",
						img: "",
						msg: null,
						msgText: "<em>Loading.</em>",
						selector: null,
						speed: 'fast',
						start: undefined
			navSelector  : "#nav-below",            
						   // selector for the paged navigation (it will be hidden)
			nextSelector : "div .nav-previous a:first",    
						   // selector for the NEXT link (to page 2)
			itemSelector : ".article"          
						   // selector for all items you'll retrieve
		  // unbind normal behavior. needs to occur after normal infinite scroll setup.
				return false;

Open in new window

Which works perfectly except for the back button, any suggestions this is a wordpress site


Avatar of eemit
Flag of Germany image

Try this:
//Click event to scroll to top
	$('html, body').animate({scrollTop : 0}, 800);
	return false;

Open in new window

Assumes you have this in your template:
<p class="scroll-to-top"><a href="#" >Scroll to top</a></p>

Open in new window

Avatar of john_yourspace


Hi Eemit,

I am not sure how this will work,

The problem is the user scrolls through a number of pages using infinite scroll

so for example he scrolls to page 10 and clicks through to a post , when the back button is used the user is back on page one
Put that in jQuery(document).ready function e.g.:
	// put the code I posted in here.

Open in new window

but i dont want to scroll to the top?
Oh sorry! my bad!
no problem
Did you saw how Facebook and Google+ handled this issue ?
is it hash bang or?
Are you using the Infinite Scroll plug-in, or something hand-rolled?

What version of WordPress are you using?
using the js from

I wonder if that problem is related to this post:

Screw Hashbangs: Building the Ultimate Infinite Scroll
Thanks Bob I seen  that, found it tough to understand, we didnt bother implementing it in the end
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial