提问人:Vincent Tupper 提问时间:11/16/2023 更新时间:11/16/2023 访问量:38
iframe 中的出站链接未打开
outbound link within an iframe not opening
问:
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>®</span> Fugiat occaecat consequat labore anim incididunt irure adipisicing labore dolore veniam consequat occaecat nulla.<br> <span>•</span> Elit dolor veniam sed culpa quis est do dolore velit minim nulla.<br> <span>•</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>
答: 暂无答案
评论
X-FRAME-OPTIONS
标头,以便第三方网站无法在 iframe 中显示它们,以防止欺骗/网络钓鱼攻击