-3

Here my code

<a target="_blank" href="#" onclick="window.open('https://www.google.com','_blank');">
  <img src="#{request.contextPath}/resources/img/landing-page/terdaftar-kominfo.png" />
</a>
Kyojimaru
  • 2,659
  • 1
  • 12
  • 21
莎拉Sarah
  • 79
  • 1
  • 5

1 Answers1

1

You don't need to use Javascript (onclick). The HTML tag target="_blank" already means "Open the link in a new tab" :

<a target="_blank" href="https://www.google.com">
  <img src="https://via.placeholder.com/150" />
</a>

Note that the link doesn't work here, in the snippet, probably because it's sandboxed. But try it from an HTML file and it will work.

Kyojimaru
  • 2,659
  • 1
  • 12
  • 21
Jeremy Thille
  • 25,196
  • 9
  • 41
  • 59