当用户单击"open in a new tab"时,如何在iframe内重定向链接?



我正在开发一个允许用户使用一堆服务(Spark等)的Web应用程序。当用户选择启动服务时,假设Spark,应用程序将打开一个新选项卡,其中将有我的页面(服务.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内链接上的"在新选项卡中打开"时,它将重定向到我的服务.html页面,而不是 http://localhost:{{port}}/{{page}}?

谢谢,如果我不清楚,对不起。

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

最新更新