Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Confluence remove HTML target attribute from link in user macro

Marc Wampfler May 21, 2019

Hi,

I wrote a "User Macro" to add links with some options.

In the user macro is a link with the HTML attribute "target", but if I'm using the user macro, the "target" attribute is missing.

What is my fault? 

SIMPLIFIED user macro CODE (there is much more code in the user macro)

## @param Target:title=How to open the link|type=enum|enumValues=New,Current|default=Current Window|desc=Defines how the link will be opened.

#if( $paramTarget == "New" )
#set( $target = "_blank" )
#else
#set( $target = "_self" )
#end

<a href="http://www.google.com" target="$target" data-target="$target">Google</a>

 

The "target" attribute is set correct, see the "data-target" attribute.
The HTML source code resulting in

<a href="http://www.google.com" data-target="_self" class="external-link conf-macro output-inline" rel="nofollow" data-hasbody="false" data-macro-name="av-test-macro-code">Google</a>

 

I knew the workaround "adding javascript code to add the target attribute based on the external-link class". 

2 answers

0 votes
Ulrik Schoth November 21, 2021

Hi @Marc Wampfler, have you found a solution in the meantime?

Marco April 25, 2022

Hi @Marc Wampfler and @Ulrik Schoth , i suppose this issue relates to CONFSERVER-54958

Best regards, Marco

0 votes
Brant Schroeder
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 15, 2021

@Marc Wampfler 

Take a look at this article https://confluence.atlassian.com/confkb/how-do-i-make-my-attachments-open-in-a-new-window-or-tab-313459830.html

Looks like the target needs an _ in front of it.  You can try it and see if that works.

Ulrik Schoth November 21, 2021

The linked article shows the underscore only in the example 

<A href="newwindow.html" _TARGET="_blank"_>a new window</A>

and not in the preceding text: You need to add a TARGET = "_blank" to the <a href> HTML tag.

I guess the underscore in the example is a typo: If you use it, the whole attribute goes through but the browser does not recognize it.

So, this suggestion does not help unfortunately.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events