iframe 中的出站链接未打开

outbound link within an iframe not opening

提问人:Vincent Tupper 提问时间:11/16/2023 更新时间:11/16/2023 访问量:38

问:

iframe 是从包含基本文本和一些出站链接的 html 文件呈现的。尝试打开 iframe 时 iframe 中的链接当前将在 iframe 中打开。

我尝试添加或,但是当您单击它时没有任何反应,这与我在 stackoverflow 或其他说可以解决问题的网站上看到的相同。我通过 javascript 尝试了其他方法,包括链接上的事件侦听器,然后是 window.open(url, _blank) 等。我尝试更改沙盒设置并研究沙盒,但这并没有解决问题。target="_blank"target="_top"target="..."allow-popups allow-popups-to-escape-sandbox

iframe 的第一个代码是:<gwd-iframe id="gwd-iframe_1" source="" class="gwd-iframe-op97"></gwd-iframe>

我有一些javascript,它使用srcdoc来替换iframe的内部,因此它不需要外部.html文件来填充它,并且html可以保存在变量中:

function iframeSrc() {
  const iframe = document.getElementById('gwd-iframe_1');
  iframe.srcdoc = iframeInner;
}

iframe 中的代码:(对于此用例,链接指向 stackoverflow)

<div style="color: black; font-size: 11px; font-family: Oswald, sans-serif; overflow-x: hidden; word-wrap: break-word; line-height: 1.4;">
  <p style="margin-top: 0 !important"> <span style="color: #8e5295"><strong>Exercitation incididunt tempor.</strong></span><br> <strong>Dolore minim cupidatat.</strong> <br> </p>
  <p><strong>lorem</strong><br> ipsum<span>&#174;</span> Fugiat occaecat consequat labore anim incididunt irure adipisicing labore dolore veniam consequat occaecat nulla.<br> <span>&#8226;</span> Elit dolor veniam sed culpa quis est do dolore velit minim nulla.<br> <span>&#8226;</span> Anim ut in irure id cupidatat quis cupidatat eiusmod ex irure reprehenderit elit in ad.<sup>2</sup> </p>
  <p><strong>References</strong> Veniam amet. <a href="https://stackoverflow.com/">https://stackoverflow.com/</a></p>
</div>
JavaScript HTML iframe

评论

1赞 Rory McCrossan 11/16/2023
单击链接后,请检查控制台是否有错误。许多网站将设置 X-FRAME-OPTIONS 标头,以便第三方网站无法在 iframe 中显示它们,以防止欺骗/网络钓鱼攻击
0赞 Vincent Tupper 11/16/2023
当我单击链接时,控制台中有 0 个错误,这是最令人困惑的事情。我什至找不到任何东西来真正去研究修复程序

答: 暂无答案