javascript - 当用户单击“在新选项卡中打开”时,如何重定向 iframe 内的链接?
问题描述
我正在开发一个让用户使用一堆服务(火花等)的网络应用程序。当用户选择启动服务时,比如 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 }}?
谢谢,对不起,如果我不清楚。
解决方案
<a href="..." target="_top">My Link</a>
在框架链接中使用
推荐阅读
- c# - 在 C# 中创建以 30 分钟分隔的小时列表
- reactjs - 我无法让 React Transition Group 工作。没有进入或离开过渡
- android - 将 Android MaterialTimePicker 对话框限制为小时和分钟的特定值
- node.js - 订阅 thingsboard 主题时,mqtt 客户端断开连接
- r - 如何在 R 的同一列中将 K 替换为千和 M 替换为百万
- azure-devops - Azure 二头肌存储帐户 sku 是只读的
- flutter - 如何使用 Flutter/Dart 抓取 img 标签的“数据”属性值
- linux - 通过 Vundle 安装 nvim-tree.lua 但其命令不存在
- javascript - React Unhandled Rejection (Error):动作必须是普通对象。相反,实际的类型是:'Promise'
- sas - 如何通过sas中的另一列值删除单词