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
@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:
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.
I used your code on my website (life saver thank you!). I have one issue i was wondering if you could help with. As you can see the dropdowns on my product page all link to the right tabs, but once you’re actually on the products page, all the dropdowns are grey and don’t link to anything. Is there a way around this?
Yeah sure, sorry forgot you can only see the problem when its published! The published link is www.modutherm.co.uk. In both of the screenshots i’m hovering over the dropdown links.