cptully
cptully

Reputation: 697

Using Thymeleaf to create links that open in a new window/tab

In basic HTML, a link can have the target="_blank" property to force it to open in a new window or tab. But if when I put that in an <a href> tag that also includes a th:href for Thymeleaf, Thymeleaf overwrites the whole tag and wipes out my target="_blank.

I've considered the brute force method of adding target="_blank" to every link as it is stored in my database so that it is already part of the link when Thymeleaf writes it out. But I would prefer a way to have Thymeleaf write the target="_blank" property as it is writing the <a> tag.

Upvotes: 8

Views: 11857

Answers (1)

kjsebastian
kjsebastian

Reputation: 1279

Thymeleaf overwrites the a tag. Use th:target="_blank".

Upvotes: 16

Related Questions