【问题标题】:<a> tag target=_blank from an iframe to a new window<a> 标记 target=_blank 从 iframe 到新窗口
【发布时间】:2021-01-21 22:01:13
【问题描述】:

我必须在新窗口中加载页面,而我的&lt;a href&gt; 在 iframe 中,所以它不起作用。该链接在同一个 iframe 中打开,我不希望这样,我希望它在一个全新的窗口中。请问有谁知道解决办法吗?

<a href="https://www.sciencedirect.com/science/article/abs/pii/S0944711316301891" id="lien" target="_blank">Lien vers une étude publiée sur ScienceDirect</a>

^我不希望它加载到按钮所在的 iframe 中

【问题讨论】:

    标签: html iframe href


    【解决方案1】:

    使用 javascript 的 window.open() 。你可以从&lt;a&gt; 标签启动它。 https://developer.mozilla.org/en-US/docs/Web/API/Window/open

    【讨论】:

    • 基本上我会在我的ahref上做&lt;script&gt; myfunction { "window.open(https://www.sciencedirect.com/science/article/abs/pii/S0944711316301891", "_blank" } &lt;/script&gt; and then add onclick="myfunction()"
    • 你也可以&lt;a href="javascript:window.open()" .... 并且 IMO 你需要另一个名字而不是 _blank,但试试吧
    • 工作得很好,感谢您在截止日期前几个小时为我节省了时间
    猜你喜欢
    • 1970-01-01
    • 2015-01-16
    • 2011-02-02
    • 2010-12-22
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 2013-02-28
    • 1970-01-01
    相关资源
    最近更新 更多