当用户单击“在新标签页中打开”时,如何重定向iframe中的链接?

时间:2019-01-07 09:58:33

标签: javascript python html web

我正在使用一个网络应用程序,该应用程序允许用户使用一堆服务(火花等)。 当用户选择启动服务(例如Spark)时,该应用程序将打开一个新标签,其中会有我的页面(service.html),其中包含有关用户的一些信息,然后是iframe,如下所示:

 <table width="100%" style="padding: 0px;">
            <tr>
                <td align="right" style="padding: 0px;">
                    <i class="fa fa-wifi" style="color:gray;"> {{ some stuff}}</i>
                </td>
            </tr>
  </table>
  <iframe id="serviceIframe" width="100%" height="100%" frameborder="0" src="http://localhost:{{port}}/{{page}}" target="_self"/>

一切正常,但是我的问题是,如果用户在iframe中的任何链接上单击“在新标签页中打开”,它将进入http://localhost:{{port}} / {{page }},而不是为html提供服务,我想要在服务旁边显示的内容将会丢失。

该怎么办,当用户单击iframe内链接上的“在新标签页中打开”时,它将重定向到我的service.html页面,而不是http://localhost:{{port}} / {{page}}?

如果不清楚,谢谢。

1 个答案:

答案 0 :(得分:0)

在框架链接中使用<a href="..." target="_top">My Link</a>