-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,694
  • 1
  • 14
  • 22
莎拉Sarah
  • 99
  • 1
  • 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,694
  • 1
  • 14
  • 22
Jeremy Thille
  • 26,047
  • 12
  • 43
  • 63