The code use following libraries:
- jQuery 2.0
- jQuery UI 1.10.3
jQuery.address 1.6
$(document).ready(function() { flag = true; $(".myclass").tabs({ activate: function(event, ui) { if(!event.originalEvent) return; var parent_id; parent_id = $(ui.newPanel).parents(".myclass").parents('.ui-tabs-panel').attr('id'); flag=false; if(typeof parent_id !== 'undefined') { window.location.hash = '#t=' + $(".myclass:eq(0)").tabs("option", "active") + ',' + ui.newTab.index(); } else { window.location.hash = '#t=' + ui.newTab.index(); } } }); $.address.change(function(event) { if(!flag) { flag = true; return; } var param = ''; param = window.location.hash; if(param.indexOf('t=') > 0) { var regexp = /#t=(.+)/i; var hash = param.match(regexp); if(hash.length > 0) { hash = hash[1].split(","); $(".myclass:eq(0)").tabs("option", "active", parseInt(hash[0])); if(hash.length > 1) $('.myclass:eq(0) .ui-tabs-panel:visible').find(".myclass").tabs("option", "active", parseInt(hash[1])); else $('.myclass:eq(0) .ui-tabs-panel:visible').find(".myclass").tabs("option", "active", 0); } } }); });