몇 가지 솔루션 (여기에서 지원 : http://bit.ly/1qIemCh)을 조합하여 실용적인 솔루션으로 응축 한 후에는 AngularJS
+ Bootstrap Tabs
을 허용했습니다. 요령은 HTML5 pushstate
을 활용하여 JS의 기록에서 URL 해시를 가져 와서 해당 탭을 찾아서 보여주는 것입니다.
탭 :
<ul class="nav nav-tabs" role="tablist" id="myTab">
<li class="active"><a href="#" data-target="#">Home</a></li>
<li><a href="#/tab2" data-target="#">Tab 2</a></li>
<li><a href="#/tab3" data-target="#">Tab 3</a></li>
</ul>
이 JS
역사에서 또는 북마크를 통해 너무 탐색되는 경우 적절한 탭이 활성화됩니다 :
function setActiveTab() {
var hash = window.location.hash;
var activeTab = $('.nav-tabs a[href="' + hash + '"]');
if (activeTab.length) {
activeTab.tab('show');
} else {
$('.nav-tabs a:first').tab('show');
}
};
//If a bookmark was used to a particular page, make sure to
//activate the correct tab after initial load:
$(document).ready(function() {
setActiveTab();
});
//When history.pushState() activates the popstate event, switch to the currently
//selected tab aligning with the page being navigated to from history.
$(window).on('popstate', function() {
setActiveTab();
});
을