Streaming live at 10am (PST)

Link to Tabs Help Please :)

Hey,

I’m trying to link to a tab on a different page from those 3 buttons on the home page to the appartment page:

I had achieved this before using this guide:


However, I can’t seem to get it to work. I’m sure its a pretty obvious mistake I made but I cant seem to find it.
If someone would be kind enough to have a quick look I’d appreciate it a lot :slight_smile:


https://preview.webflow.com/preview/seeschloessle?utm_medium=preview_link&utm_source=designer&utm_content=seeschloessle&preview=64eba4c9d00b985371fedf039fc3a953&mode=preview

@MaxWebflow - you need to assign classes to each tab that match up with the query string parameter being passed through, for example:

/appartments?tab=einzimmer

The button here needs a class of einzimmer on it:

image

image

Or it looks like you’ve added IDs to the tabs, in which case modify the code to be something like this:

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

  $('#' + tabName).triggerHandler('click'); // this is the only change

  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>

It also looks like you only have the code embedded on the home page, add it to your custom code in site settings so it is added to every page.

Thanks for taking the time Sam!!
It was the first indeed, I didnt add the classes :roll_eyes:.

1 Like