Juanito Fatas
Juanito Fatas

Reputation: 9969

Cannot open link in a new tab inside iframe

Given src.html:

<html>
<body>
<p>
  <a href="https://stackoverflow.com" target="_blank" rel="noopener noreferrer">StackOverflow</a>
</p>
</body>
</html>

and iframe.html

<html>
<head>
  <title>Test iframe</title>
</head>
<body>

  <iframe sandbox="allow-scripts" src="src.html">
  </iframe>

</body>
</html>

When I click StackOverflow link, it cannot open on a new tab.


Upvotes: 1

Views: 630

Answers (1)

Juanito Fatas
Juanito Fatas

Reputation: 9969

according to MDN documentation: iframe, the sandbox attribute needs to set to allow-popups:

Allows popups (such as window.open(), target="_blank", or showModalDialog()). If this keyword is not used, the popup will silently fail to open.

Upvotes: 2

Related Questions