选项卡滑块的 Jquery 历史记录 cookie?
我正在尝试让 cookie 记住选项卡式滑块的最后位置...
$(function() {
$( ".propgnav" ).tabs({
cookie: {
expires: 1
}
});
});
上面的代码有点有效...但它只记住选择的初始选项卡。例如,如果我单击初始选项卡后的另一个选项卡,然后在浏览器中按回,则仍会选择初始选项卡。 :S
我正在使用控制滑块的选项卡: http://jqueryfordesigners.com/demo/coda-slider.html
并且选项卡导航使用哈希...如果这使得有区别吗?我真的很困惑如何让它发挥作用。有谁知道我如何创建一个简单的 cookie,当您在浏览器/刷新页面中按回键时,它会记住最后选择的选项卡?
<ul class="propgnav">
<li><a href="#propg1">1</a></li>
<li><a href="#propg2">2</a></li>
<li><a href="#propg3">3</a></li>
<li><a href="#propg4">4</a></li>
<li><a href="#propg5">5</a></li>
</ul>
I'm trying to get a cookie to remember the last position of a tabbed slider...
$(function() {
$( ".propgnav" ).tabs({
cookie: {
expires: 1
}
});
});
The above code kinda works....but it only remembers the initial tab that is selected. For example, if I click on another tab after the initial tab and then press back in the browser, the initial tab will still be selected.. :S
I'm using tabs that control a slider: http://jqueryfordesigners.com/demo/coda-slider.html
And the tab navigation uses hashes...if that makes a difference? I'm really confused with how to get this to work. Does anyone know how I could create a simple cookie that remembers the last tab selected when you press back in the browser/refresh page?
<ul class="propgnav">
<li><a href="#propg1">1</a></li>
<li><a href="#propg2">2</a></li>
<li><a href="#propg3">3</a></li>
<li><a href="#propg4">4</a></li>
<li><a href="#propg5">5</a></li>
</ul>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当用户单击选项卡时,您需要更改 URL(@marcojohannesen 提到的哈希导航) - 简单地分配 cookie 不会对您有帮助。当浏览器返回时 - 不会触发任何就绪事件。
You need to change the URL (hash navigation as mentioned by @marcojohannesen) when the user clicks the tab - simply assigning the cookie isn't going to help you. When the browser goes back - no ready events are fired.