0

I'm working on a web app where I have two anchor tags inside an iframe with the same domain as the parent:

<iframe src="same_domain_as_parent">
  <a href="google.com" target="hello">Go to google</a>
  <a href="youtube.com" target="hello">Go to youtube</a>
</iframe>

What I would like is to have both links inside the iframe open in the same tab, even after the parent windows has been reloaded. Just like they would behave outside of the iframe.

The behaviour now:

  1. Clicking on google-link opens google.com in a new tab

  2. Clicking on youtube-link opens youtube.com in the same tab as 1.

  3. Refresh parent window

  4. Clicking on google-link opens google.com in a new tab

What I would like:

  1. Clicking on google-link opens google.com in a new tab

  2. Clicking on youtube-link opens youtube.com in the same tab as 1.

  3. Refresh parent window

  4. Clicking on google-link opens google.com in the same tab as 1. and 2.

It seems that when refreshing the parent window, the context (?) of the iframe resets and links opens in a new tab. This isn't the case for anchor tags in the parent window, which still targets the same tab even after refresh. How can I achieve this within the iframe as well?

Bajenlelle
  • 11
  • 2
  • Possible duplicate of [How to make all links in an iframe open in new tab](https://stackoverflow.com/questions/22808065/how-to-make-all-links-in-an-iframe-open-in-new-tab) – Hariharan V. Aug 27 '19 at 10:26
  • I am specifically asking about the case when the parent window has been refreshed. I can't find the answer to this in the post you've linked @HariharanV. – Bajenlelle Aug 27 '19 at 12:28

0 Answers0