Hi, I have a tab and I want to open specific tab with URL. What I’ve been done to do this is :
<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>
That script is works fine with this URL http://example.webflow.io/faq?tab=cafe but I want to change that URL with this http://example.webflow.io/faq#cafe
Anyone know how to make that script works with that URL ? Thank you.
vincent
(Vincent Bidaux)
February 5, 2018, 9:46am
2
Hi, there’s a known easy method to target a specific TAB with a link. Here’s a link to @danro ’s post:
Hi @jhotujec , the only way to do this currently is by inserting some custom code.
Here is an example, which you can copy into your </body> code section.
<script>
$('.custom-button').on('click', function (evt) {
$('.target-tab-link').triggerHandler('click');
evt.preventDefault();
});
</script>
Then in the webflow designer, you would need to assign these special classes (without the leading dot) to the respective elements:
Custom button: custom-button
Target tab link: target-tab-…
The URL you’d want to use is actually a working URL with anchor to an ID. (links to the element with ID #cafe ). I don’t know if it’s possible to make it target what you want instead.