Cameron Kilgore
Cameron Kilgore

Reputation: 423

Opening links in a new tab and only the new tab

I need to open a new tab or popup window, and then any other time the original source link is clicked, it updates the already open tab or window. Right now it just keeps opening a new tab and that's not the behavior that's expected.

Upvotes: 2

Views: 449

Answers (1)

Ry-
Ry-

Reputation: 225281

Specify a custom target name:

<a href="something.html" target="otherpage">Go to some page #1</a>
<a href="something2.html" target="otherpage">Go to some page #2</a>

This will "name" the other window/tab and open links with the same target in that page, or in a new window/tab if one doesn't already exist. You can achieve the same effect with window.open by specifying the name as the second argument.

Upvotes: 5

Related Questions