我需要在同一父页面中打开链接,而不是在新页面中打开它。
注意: iframe
和父页面是同一域 。
#1楼
使用目标属性:
<a target="_parent" href="http://url.org">link</a>
#2楼
尝试在anchor tag
target="_parent"
属性 。
#3楼
如前所述,您可以使用target属性,但是XHTML在技术上已弃用该属性。 parent.window.location
就是使用javascript,通常是parent.window.location
类的parent.window.location
。
#4楼
使用JavaScript:
window.parent.location.href= "http://www.google.com";
#5楼
有一个名为base
的HTML元素,它允许您执行以下操作:
为页面上的所有链接指定默认URL和默认目标:
<base target="_blank" />
通过指定_blank
,可以确保iframe内部的所有链接都将在外部打开。
来源:oschina
链接:https://my.oschina.net/stackoom/blog/3186817