11

I have a website that is on a slide show and when the user presses the back button I would like it to go back to the album view not the prior and prevent page. Is there a way of doing this? thanks for any help or advice.

user516883
  • 8,868
  • 23
  • 72
  • 114

2 Answers2

15

jQuery Address provides strong cross-browser support for browser history and Ajax crawling:

http://www.asual.com/jquery/address

http://github.com/asual/jquery-address

Greetings

UPDATE:

you can find a good sample right here:

http://jsfiddle.net/5L6Ur/10/

some code in short:

 $(function() {
    $('a').click(function(e) {
        e.preventDefault();
        $.address.value($(this).attr('href'));
    });
    var changecount = 0;
    $.address.change(function(e) {
        if (typeof e !== 'function') {
            $('span').html(changecount++);
        }
    });
 });​
Simone
  • 636
  • 2
  • 8
  • 25
MUG4N
  • 19,377
  • 11
  • 56
  • 83
  • Did you download jquery.address-1.5 from first link I provided? – MUG4N Jun 25 '13 at 19:11
  • @MUG4N yes, i included the the file right after `jquery` ` ` – t q Jul 09 '13 at 15:06
  • @MUG4N getting errors: `Uncaught TypeError: Cannot read property 'version' of undefined jquery.address- Uncaught TypeError: Cannot call method 'change' of undefined ` – t q Jul 09 '13 at 15:08
  • 1
    @MUG4N found the solution, `` – t q Jul 09 '13 at 16:56
4

You should:

  1. Set location.hash when page state changes.
  2. When location.hash changed by user (for example, by pressing back button) render appropriate page contents.
Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127