【问题标题】:anchor tag target iframe not working and link opening in new tab锚标记目标 iframe 不起作用并在新选项卡中打开链接
【发布时间】:2022-01-10 18:05:18
【问题描述】:

点击链接后,链接会在浏览器的新标签页中打开,而不是在iframe 中,iframe 是一个空白框

<iframe name="iframenew" height="300px" width="100%" title="Iframe Example"></iframe>
<p><a href="https://alight.com" target="iframenew">AVA</a></p>

我希望链接在iframe 本身中打开

【问题讨论】:

  • 该代码应该可以正常工作。
  • 工作正常,我在 Firefox 中试过
  • 好奇我的回答能否解决您的问题

标签: javascript html iframe


【解决方案1】:

你是指消息alight.com refused to connect.吗?

某些网站禁用嵌入iframe,您可以使用X-Frame-Options检查

在尝试将 iFrame 嵌入您的课程时,您可能偶尔会遇到一些错误,例如看到空白白框或错误通知。这是因为并非所有网站都可以嵌入。

<iframe name="iframenew" height="300px" width="100%" title="Iframe Example"></iframe>
<p><a href="https://alight.com" target="iframenew">AVA</a></p>

代码没有问题,你可以在下面看到,我将链接切换到维基百科主页,它会找到。

<iframe name="iframenew" height="300px" width="100%" title="Iframe Example"></iframe>
<p><a href="https://en.wikipedia.org/wiki/Main_Page" target="iframenew">AVA</a></p>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-12
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-25
    • 2012-06-22
    相关资源
    最近更新 更多