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.

2021-02-03 21.19.15


Here is my site Read-Only: https://preview.webflow.com/preview/teh-saneeraus?utm_medium=preview_link&utm_source=dashboard&utm_content=teh-saneeraus&preview=27704f26a869cc52e44bd7b56662fbd9&mode=preview (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