处理JavaScript中的浏览器后退按钮 [英] Handling browser back button in javascript

查看:125
本文介绍了处理JavaScript中的浏览器后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要处理JavaScript中的浏览器后退按钮.我已经在JS中实现了选项卡功能.因此,我希望用户返回到他们导航到另一个页面的确切时间.

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 another page.

我可以将选项卡#保留在某些隐藏的输入字段中.并在javascript中进行检查.

I can keep the tab # in some hidden input field. and check with the same in javascript.

但是,当用户点击后退按钮时,如何确保在javascript中调用了函数.一些帮助,将不胜感激.

But how do I make sure that a function gets called in javascript when the user hits the back button. some help would be appreciated.

推荐答案

此插件(来自jQuery工具)完全满足您的要求.

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:

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>

这篇关于处理JavaScript中的浏览器后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆