you need to set the current selected tab in the javascript cookie and always read this cookie when the page loads and set the tab
you can set a cookie inside the newTab () function:
function newTab() { var form1 = document.createElement("form"); form1.id = "newTab1" form1.method = "GET"; form1.action = "domainname"; //My site address form1.target = "framename"; //Browser tab name $.cookie("currentTab", "framename");//set the selected tab name in cookie document.body.appendChild(form1); form1.submit(); }
then on the page load event:
var tabName=$.cookie("currentTab")//get the current tab name from cookie. if(tabName==null){ tabName="default tab name"//at first time the cookie will be null, //so you need to assign a default value if the cookie is null } //set this tab as selected
source share