Streaming live at 10am (PST)

Link to tab inside a tab

Hello!

So far I’ve used this code before </body> tag to link to a specific tab in different page:

<script>
var Webflow = Webflow || [];
Webflow.push(function () {
  var tabName = getParam('tab');
  if (!tabName) return;

  $('.' + tabName).triggerHandler('click');

  function getParam(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
      results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
  }
});
</script>

But I’ve come to a problem: How do I link to a tab, inside a tab?

Here’s an gif to demonstrate how it currently goes wrong. It technically does link to the 2018 tab, but it doesn’t link to Saneerauskohteet tab first and then to 2018 tab.


Here is my site Read-Only: Webflow - TEH saneeraus (It’s the Referenssit 2 page)

Actually I found a solution from an older post, I just had to google “linking to nested tabs”. :smiley:

So sharing from the post in here, posted by samliew, change the </body> code to this:

function getParam(name) {
  name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
    results = regex.exec(location.search);
  return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var Webflow = Webflow || [];
Webflow.push(function () {
  var tabName = getParam('tab');
  var subTabName = getParam('subtab');
  if (tabName) $('.' + tabName).trigger('click');
  if (subTabName) $('.' + subTabName).trigger('click');
});

And then the url should be written like this:
/insertyourpage?tab=inserttabname&?subtab=insertsubtabname

So in my case:
/referenssit-2?tab=san&?subtab=san2018