链接图像新选项卡在 Mozilla 中不起作用,但在 chrome 中工作正常



我的代码

<a target="_blank" href="#" onclick="window.open('https://www.google.com','_blank');">
<img src="#{request.contextPath}/resources/img/landing-page/terdaftar-kominfo.png" />
</a>

你不需要使用Javascript (onclick)。HTML标签target="_blank"已经表示"在新标签中打开链接";:

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

注意,在代码片段中,链接在这里不起作用,可能是因为它被沙盒化了。但是在HTML文件中尝试一下,它会工作的。

相关内容

最新更新