Link to Open on Another Page AND ON THE SAME PAGE

Hey, I have built a system through which I can go directly to a specific tab on another page via a link on my footer.
It works fine but the problem is that it only works when I am on another page.
If I am on the page where the tabs are it only scrolls to the section but does not open the desired tab.
(This is how it should work, from the tutorial)

The Tutorial

This is the Code he use

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

After that in the link you should simply enter “/?tab=yourtab#yoursection”

Maybe someone can make a small change in the code, so that the functionality also remains on the page where the tabs are.

Thanks!

I think I don’t need to send my page in as it is not a bug but just a matter of custom code