Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is href link with target="tabname" not working

Tags:

html

This was working the first time I tried it, would re-use the same tab as target if it exists and create if it does not

<a href="www.example.com/help/section3" target="helpTab" class="helpButton">Help</a> 

Later when I tried the link I noticed it was creating new tabs over and over if i clicked it multiple times, and not re-useing that tab it already made.

so I tried using the java window.open:

<a onclick="window.open('http://example.com/help/#section1', 'helpTab'); return false" class="helpButton">Help</a>

and still it keeps opening in new tabs over and over again.

what would cause it to stop working or what am I doing wrong?

like image 342
Nolan Ritchie Avatar asked Aug 31 '25 18:08

Nolan Ritchie


1 Answers

I had this issue recently and found two possible reasons that target="helpTab" might have stopped working:

  1. If the target URL (www.example.com/help/section3) redirects to another URL, this will prevent the tab from being reused.
  2. If you have a mismatch in the Cross-Origin-Opener-Policy HTTP header between the original page and the target page, it can prevent the tab from being reused.

In my case, I had only set Cross-Origin-Opener-Policy: same-origin on the target page. The solution was to also set the same header on the original page.

like image 71
Matt Avatar answered Sep 02 '25 08:09

Matt