Support » Plugin: Table of Contents Plus » Opening a page in a new tab

Viewing 6 replies - 1 through 6 (of 6 total)
  • Please do not open links in new tabs or windows without warning the user in clear text on the page. This kind of site behaviour breaks the browser Back button & can leave some user groups stranded on the new tab with absolutely no way of getting back to your site.

    If your site contains decent content, your visitors will either make their way back to the page or will open links in new tabs using their controls in their own browsers.

    Thanks for your answer but that’s not what I’m looking for. My boss requested it this way so that’s what I have to do. It’s not for a site that’s available to the public, so I’m not concerned about visitors making their way back to the TOC.

    [Moderator Note: No bumping. If it’s that urgent, consider hiring someone.]

    Plugin Author Mike


    I don’t understand why your boss would want to do that seeing that the TOC links to headings on the current page! For each link someone clicks on, it’ll be loading the same page, except it will be at a different position. When the user prints the page, they’ll get all the content, not just the section that popped up.

    Maybe the content should be broken up into nested pages instead?

    There are other more elegant ways and promotes usability too:

    1. Fix the TOC so it is always visible and to the side as the user scrolls or moves between headings.

    2. You could also highlight the section of the TOC that the user is currently in.

    3. Use smooth scrolling to animate to the headings to give a ‘wow’ effect.

    For an example of the 1 and 2, take a look at Bootstrap and start scrolling.

    Edit: there is no existing option to open in new windows – don’t hold your breath either as I would not be recommending this approach.

    I understand that. I personally did not create the page that has the TOC on it, I was just requested to see if I can get each entry on the TOC to open in a new tab. Unless there is something I’m missing, I don’t understand why this is being made to be so difficult.

    This is the page I’m working with.

    I just want to be able to click on an entry and have it open in a separate tab. Is that possible?

    Plugin Author Mike


    Hmm, I thought you were talking about the TOC at the top linking to the headings within the content, rather than the sitemap posts shortcode which was why I was really against that thought.

    Anyway, no options exist to open in a new tab so you’ll need to modify the file. Line 368, you’ll need to add target=”_blank”, something like:

    $html .= '<li><a target="_blank" href="' . get_permalink($articles->post->ID) . '">' . $title . '</a></li>';

    I don’t normally recommend changing plugin code as you’ll need to reapply with updates. If you can add your own jquery then you could get the same effect.

    That worked great! Thank you so much!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Opening a page in a new tab’ is closed to new replies.