Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence jira-issue macro links to open in a new window

Matt Michal
Contributor
June 13, 2013

http://jsfiddle.net/buDxG/

See above link for a working sample where the links inside jira-issue macro are properly having the target attribute set to _blank. However, when this is actually added to the end of the HEAD via Custom HTML, inspecting jira-issue links shows that the target is "" (no value).

Is there any way to have jira-issue links open in a new tab/window?

Confluence 5.1 with minimal customization or other plugins installed.

<!-- open external links in a new window -->
<script>
jQuery(document).ready(function() {
    jQuery(".external-link").attr("target", "_blank");
    jQuery(".jira-issue a").attr("target", "_blank");
});
</script>

2 answers

0 votes
nriley
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 13, 2013

Hey Matt,

In theory this should work. I attempted a similar method internally (using the HTML Macro) and it worked fine.

I would try a couple things (following from: https://confluence.atlassian.com/display/CONFKB/How+to+Use+JavaScript+in+Confluence)

1. While it's nitpicking, I would add a: type="text/javascript" to your script tag.

2. Confluence wraps jQuery in another function, AJS. You can use all the jQuery functionality by calling something like

AJS.$('div.foo');

I would modify your jQuery calls using AJS instead. You can test if this works by throwing an alert() or console.log() function inside your .ready() call, to confirm that your function is firing off as expected.

Matt Michal
Contributor
June 14, 2013

I've changed to the below code which is at least working in Firefox and Chrome (after you wait a while for the load even to fire). This is not working in IE and I'm not sure how you got yours to work with the ready event as I still can't get it to work in any browser with that event.

<!-- open external links in a new window -->
<script type="text/javascript">
AJS.$(document).ready(function() {
    AJS.$(".external-link").attr("target", "_blank");
});
AJS.$(window).load(function() {
    AJS.$(".jira-issue a").attr("target", "_blank");
});
</script>

Matt Michal
Contributor
June 18, 2013

Neal, what theme were you using during testing? I've seen a Chrome editor bug fix not work in with the newest documentation theme. Maybe this is something that only works in the new theme?

0 votes
Matt Michal
Contributor
June 13, 2013

Confluence 5.1 with minimal other customization.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence, loom, atlassian intelligence, ai notes, ai-powered meeting notes, atlassian community events, ace, confluence ai, loom ai integration, ai note-taking, atlassian ai features, team '25, atlassian live learning, confluence automation

Unlock AI-powered meeting notes: Join our live learning session! 📹

Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.

Register today!
AUG Leaders

Atlassian Community Events