Is there a way using Jquery to detect the back button being pressed cross browsers

后端 未结 2 675
后悔当初
后悔当初 2020-11-30 09:37

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 wa

2条回答
  •  萌比男神i
    2020-11-30 09:42

    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++);
            }
        });
     });​
    

提交回复
热议问题