Link to a tab

Hi Blocheads.
Does anyone know if it’s possible to link to a specific tab, either as a ‘scroll to target’ or ‘navigate to url’?

What do you mean with “tab”?

I have a page with a tab brick, one of which are my T & C’s, say tab 2.
I wondered if it’s possible to link directly to this tab instead of the page, defaulting to tab 1.

Hi @apswoodwork

You can do these couple of steps to have any tab open when linking to the page.

Get the Tab link ID

In my case it is #nav-42984-content-2

This needs to be added to the end of the link you are using to get to the page with the Tabbed content. Note that you need to include the # symbol and it is directly after the page name. (if you are using clean URLs you won’t have .html)

eg. /mytest.html#nav-42984-content-2

And place this script in the footer of the page that has the tabbed content.

    $(document).ready(function ($) {
        let openTab = window.location.hash;
        $('.nav-link[href="' + openTab + '"]' ).trigger('click');

Here is a video of it working for you


Hi @Malachiman
Thanks a million you clever sod! I was almost there but I didn’t know it needed a script.
This is super useful. I’m 100% using it.

1 Like

Great it works for you.

I’ll try it tomorrow.

1 Like

Hi. Just to let you know for future reference, the link to tabs code only seemed to work when there’s no other code. As soon as I add more code to the body it doesn’t. I’ll make separate pages instead of tabs to simplify things.
Worth a try tho :nerd_face:

Good to know thanks. I’ll make some changes. I only tested it in a blank project.

I’ll PM some different code if you don’t mind testing it for me.

After all the help you’ve given me; no problem.
I’ll hold back on rewriting my 2 tabbed pages.
It’s not the link itself as a r/c-‘open link in new tab’ follows link fine.
And it works on my other pages.

1 Like