views:

142

answers:

1

Hey :)

I have a little problem with some jquery and http://www.mikage.to/jquery/jquery%5Fhistory%5Fnoc.html

The function works great, my problem is to highlight an li class, tab menu, when user backspace with the keyboard or just use the back button on their browser to return the last seen page.

html code

li code with the class active, when page is on

<li class="active"><a href="#prices" rel="history"><span>Prices</span></a></li>

jquery code:

This is loaded when

$(document).ready 
    $('li > a').click(function() {
    $('li').removeClass();
    $(this).parent().addClass('active');        
});

Can i make som .... keyCode == 8 (backspace key) to return last page ? Can somebody give me a tip, or mabye give me an code example :-/

+2  A: 

I would consider storing the state in a cookie (whether or not a class has been added to an element, for instance), and re-initializing your page from the values written to the cookie within your $(document).ready function. I did something similar to keep expandy bits of the page expanded. Check out the jQuery cookie plugin.

karim79
this look very useful, can you give an example ?
william