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

2024-04-18 06:55:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个web应用程序,允许用户使用一系列服务(spark等)。 当用户选择启动一项服务时,比如说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内的链接上单击“在新选项卡中打开”时,它将重定向到my service.html页面,而不是http://localhost:{{port}/{page}

谢谢,如果我不清楚的话,我很抱歉


Tags: 用户应用程序localhosthttpstyleporthtmlservice