Solution - creating an URL link for a specific tab

Hi~ I used that script as well.

But I have a problem here:
I must set the tab selection default as “none”.
If not, for example, there are 2 tabs with the first one as default, if the URL is /page?tab=first and targets that first tab, the script will kind of “unclick” that tab and the result is none.

Does anyone know how to avoid that / how to modify the script?

( That post was closed, so I paste the code by @danro here for easy reference. )

<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>
1 Like