Search code examples
javascriptjqueryjquery-uijquery-ui-tabswindow.location

Javascript redirect to a page with jquery tabs


'I have a page where after an AJAX and js function runs I need to reload the page and go to a specific JqueryUI tab. (in this case the tab is 'tabs-b') (jquery-ui-1.8.20)

This code reloads the page, but does not go to the tabs-b (its at the default)

var formID = 'tabs-b';
window.location.href=$('survey1.php','#'+formID).val();
window.location.reload(true);

I have also tried this to the same effect:

window.location.href='survey1.php#tabs-b';
window.location.reload(true);

however when I just type it into the browser it works. I am stumped. I am fairly new to js so it may be a noob syntax error, but I have not found any other people with the same issue.


Solution

  • In you code you do not need window.location.href and window.location.reload. reload (true) will fetch from the server the current page based upon the existing url.

    Just use window.location.href