a while ago i asked this question Jquery tabs keep tab open that is subid in url and you can see that i found an answer to my question, now i am trying to alter it so that each time you change from tab to tab it changes the tid subid in the header, at the moment it just changes the variable tid to whatever the tab_id is, so that when you press back, you can open the specific tab you left from, but this time i want it to update the tid in the header as you scroll through the tabs.
In case the link to my previous answer doesn't show here is my code
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if (results == null) return "";
else return decodeURIComponent(results[1].replace(/\+/g, " "));
}
$(document).ready(function () {
$(".tab_content").hide(); //Hide all content
var tabIndex = parseInt(getParameterByName('tid'), 10);
if (!tabIndex) tabIndex = 1;
$("ul.tabs li").eq(tabIndex - 1).addClass("active").show(); //Activate first tab
$(".tab_content").eq(tabIndex - 1).show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function () {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
});
});
Let me know if you need anything else and sorry if this is a little confusing.
EDIT: In other words at the moment if i add ?tid=2 in the header then it will go to the second tab, but it will not update it automatically when you change tab