Window location href new tab

A common question!

To open a link in a new tab when clicking on a link with the href attribute, you can use the target attribute and set its value to _blank. Here's an example:

<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank">Open in new tab</a>

This will open the link in a new tab when clicked.

If you want to achieve this using JavaScript, you can use the window.open() method:

<a rel="nofollow" target="_blank" href="https://www.example.com" onclick="window.open(this.href, '_blank'); return false;">Open in new tab</a>

In this example, the onclick event is triggered when the link is clicked, and the window.open() method is used to open the link in a new tab. The return false statement prevents the default link behavior from occurring.

Alternatively, you can use the window.location.href property to achieve the same result:

<a rel="nofollow" target="_blank" href="https://www.example.com" onclick="window.location.href = this.href; window.open(this.href, '_blank'); return false;">Open in new tab</a>

This code sets the window.location.href property to the value of the href attribute, and then opens the link in a new tab using window.open().