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>
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.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Confluence 5.1 with minimal other customization.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.