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 -->
<ul id="flowtabs">
<li><a id="t1" href="#player_tab">The Player</a></li>
<li><a id="t2" href="#plugins_tab">Plugins</a></li>
<li><a id="t3" href="#streaming_tab">Streaming</a></li>
</ul>
<!-- tabs content -->
<div id="flowpanes">
<div>tab1 html here</div>
<div>tab2 html here</div>
<div>tab3 html here</div>
</div>
Javascript:
<script src="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"