jQuery UI 选项卡,单击不同选项卡时更新 url [英] jQuery UI tabs, update url when clicking on a different tab
本文介绍了jQuery UI 选项卡,单击不同选项卡时更新 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 jQuery UI 的选项卡:http://jqueryui.com/demos/tabs/
I'm using the tabs of jQuery UI: http://jqueryui.com/demos/tabs/
如何在用户点击不同标签时通过添加锚链接来更新浏览器的当前网址:ex: url.html#tab-4 并同时推送浏览器的当前历史记录.
How to update the current url of the browser when the user click on a different tab by adding the anchor link to it: ex: url.html#tab-4 and pushing the current history of the browser at the same time.
谢谢!
推荐答案
这应该得到你想要的(使用 jQuery UI 1.8,在 1.9 及更高版本中使用 激活事件,请参阅代码示例的其他答案).我在 jQuery UI 演示中使用了示例 HTML;
This should get what you want (using jQuery UI 1.8, in version 1.9 and later use the activate event, see other answers for code example). I used the sample HTML in jQuery UI demos;
$( "#tabs" ).tabs({
select: function(event, ui) {
window.location.hash = ui.tab.hash;
}
});
这篇关于jQuery UI 选项卡,单击不同选项卡时更新 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文