Attachments Opening in a New Tab

Comments

4 comments

  • Avatar
    Steffen Burzlaff

    Hi Arianna,

    how did you implemented the attachments. Are they coming through Confluence within the $page.content placeholder?
    Or are they rendered via an macro or are they rendered dynamically within the theme?

    Can you give me an example of an attachment link and how you implemented it?

    Thanks and have a nice day.

    Best Regards,

    Steffen

  • Avatar
    Arianna Royster

    Hey Steffan,

    I actually found an article to help with this: 

    https://confluence.atlassian.com/confkb/how-to-force-links-to-open-in-a-new-window-213518072.html?_ga=2.173395813.714076324.1549048418-639474411.1539018779

     

    I had a question though, in this code it is telling all links to open in a new tab. Is there a way to tell it to open just the attachment links?

    The links that I want to open in a new tab have a .pdf at the end of their links and the regular links don't have it.

    Here was the script I implemented into the theme.

    <script>
    jQuery(document).ready(function() {
        jQuery(".wiki-content a").attr("target", "_blank");
    });
    </script>
  • Avatar
    Steffen Burzlaff

    Hey Arianna,

    thanks for reaching out to us.
    Sorry for the long wait on this post, sure we can move this here.

    You are able to do this with a little change in the jQuery:

    $("[href*='/files/']").attr("target", "_blank");

    Links to attachments in Scroll Viewport always contains "/files/" as an indicator. With that you can select all links pointing to an attachment and add the attribute.

    Let me know if that worked for you.

    Thanks and have a nice day.

    Best Regards,
    Steffen

  • Avatar
    Arianna Royster

    Thanks that solved the issue!

Please sign in to leave a comment.

Powered by Zendesk