Creating a demo site and need back buttons on the page that go in a specific order


I’m creating a demo website (pure to show design and content - not going live) and I want users to be able to click through the site and to use a back button on the site that goes back through the pages they entered.

I have these pages.

2a.html / 2b.html
3a.html / 3b.html

a user will only go to either the a or b page.

so when a user is on page 4 i need a button to link the user back to the correct version of page 3 & 4.

can anyone advise a simple way to do this (jquery plugin)?

at the moment i’m trying to use the querystring to input values but having problem persisting them/


You shouldn’t be replicating browser functionality within the window. If you want people to go back a step, use the browsers back button. It’s what people are going to click by default (not the one you stuff on the page) and thereby if the behaviour is different it may cause serious conflicts with the end user. :slight_smile:

Did you mean 2 or 3? I’m not sure exactly what you’re asking but if you’re running a local http server, this routine can use the referrer to provide a conditional back link when they arrive from the specified URLs:

<script type='text/javascript'>

function smartBack()
 for( var i = 0, args = smartBack.arguments ; i < args.length; i++ )
  if( document.referrer.match( args[i] ) )
   document.write( '<a href="' + document.referrer + '">BACK<\\/a>' );    

smartBack( "2a.html", "2b.html", "3a.html", "3b.html" );


Am I missing something? The browser back button will take you back through all the pages you have been to in the reverse order.

If you don’t want to do it that way, the window.history object contains the history. window.history.back() takes you back one page each time you invoke it. window.history.go(stepCount) takes you back the number of pages defined by stepCount (say, 2 pages).

To control all of this window.history.length tells you how many pages are in history.