In this article, we would like to show you how in a safe way create a link that is opened after a click in a new tab.
// ONLINE-RUNNER:browser; <a href="https://some-website.com/path" rel="noopener" target="_blank"> Link name </a>
// ONLINE-RUNNER:browser; <a href="https://safe-website.com/path" target="_blank"> Link name </a>
rel="noopener"is not needed if we know the link opens the safe page
In this example, we use
a element with additional properties to open the link in a new tab:
target="_blank"- specifies to open the linked page in a new tab,
rel="noreferrer noopener"- which is a good practice and helps to prevent tabnabbing and hide information about from what page the user came.
The default value of the
_selfwhich opens linked page in the current working tab.
// ONLINE-RUNNER:browser; <a href="https://dirask.com/findings" rel="noreferrer noopener" target="_blank"> Check out Dirask findings! </a>