如何强制在父窗口中打开来自 iframe 的链接 [英] How to force link from iframe to be opened in the parent window
本文介绍了如何强制在父窗口中打开来自 iframe 的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在同一个父页面中打开链接,而不是在新页面中打开它.
I need to open the link in the same parent page, instead of open it in a new page.
注意:iframe
和父页面是同一个域.
推荐答案
我发现最好的解决方案是使用 base 标签.将以下内容添加到 iframe 中的页面头部:
I found the best solution was to use the base tag. Add the following to the head of the page in the iframe:
<base target="_parent">
这将在父窗口中加载页面上的所有链接.如果您希望在新窗口中加载链接,请使用:
This will load all links on the page in the parent window. If you want your links to load in a new window, use:
<base target="_blank">
这篇关于如何强制在父窗口中打开来自 iframe 的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文