Skip to content Skip to sidebar Skip to footer

Handling Browser Back Button In Javascript

I need to handle the browser back button in javascript. I have implemented the tabs functionality in JS. So I want the user to return to the exact time from where they navigated to

Solution 1:

This plugin (from jQuery tools) does exactly what you want.

HTML:

<!-- tabs title --><ulid="flowtabs"><li><aid="t1"href="#player_tab">The Player</a></li><li><aid="t2"href="#plugins_tab">Plugins</a></li><li><aid="t3"href="#streaming_tab">Streaming</a></li></ul><!-- tabs content --><divid="flowpanes"><div>tab1 html here</div><div>tab2 html here</div><div>tab3 html here</div></div>

Javascript:

<scriptsrc="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script><script> 
$(function() {
    $("#flowtabs").tabs("#flowpanes > div", { history: true });
});
</script>

Solution 2:

how about history.go(-1) ?

$(function(){ 

$("#myLink").click(function(){ 
history.go(-1);
});

});

Solution 3:

I invite you to read this article.

Basically, it's based on the dhtmlhistory object, and it change the url in the browser.

Post a Comment for "Handling Browser Back Button In Javascript"