It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

how to define a class for a link?

Juergen Philipp Jul 10, 2012

Hi community,


following situation:
We want to open all external-links in a new window. Therefore I add the javascript in custom-html as desicriped in other questions.
That works fine - now comes the 'but' ;-)
There are also links inside a page or in the page-tree, which are inside the confluence, but the get automatically the class "external-link".

Is there any way to change that class by adding specials to the link?

Thanks for assistance.

best regards
Juergen

1 answer

0 votes
Matthew J. Horn Jul 10, 2012

I'm assuming you're using something like this in your HTML:

AJS.$("a[class='external-link']").after(' <img src="/confluence/images/main_page/external_arrow.png" alt="External Link">');

That specifically applies only to anchors (links) that are of the class "external-link". Inter-confluence links should not have that class associated with them. Under what circumstances are you seeing inter-confluence links using this class?

Also, as a side note, I add the following to open a new browser tab when a user clicks an external link:

AJS.$("a[class='external-link']").attr('target','_blank');

Makes for a nicer user experience, imho.

Juergen Philipp Jul 11, 2012

Hi Matthew,

no, I'm entering:

[back to Dashboard|http://tl-wiki.teamlines.net:8090/dashboard.action]

in the navigation-bar of "Theme navigation"
and when checking the generated HTML-code by Firebug i.e. I see that automaticall a "class='external-link'" is added.

And I add this:

<script> jQuery(document).ready(function() { jQuery(".external-link").attr("target", "_blank"); }); </script>

at the Header-part in the "Custom HTML".

I would be happy to know how to add "normal" html-language (which will not be changed/added by the interpreter) ;-) but I guess that's not possible :-(

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

860 views 0 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you