如何使iframe外部的超级链接的页面在iframe中打开a标签链接

如何使iframe外部的超级链接的页面在iframe中打开a标签链接,有以下两种方法:

 一、html方法:

<iframe name="a1"></iframe>  
<a href="http://www.baidu.com" target="a1">百度</a>

二、javascript方法:
<iframe id="a1"></iframe>  
<a href="http://www.baidu.com"  onclick="document.frames('a1').location=this.href;return false">百度</a>

反过来,如何在父窗口中打开iframe中的链接,有以下四种方法:

一、html方法 2种

<a   href=""   target="_top"></a>  
<a   href=""   target="_parent"></a>  

二、javascript方法 2种

<a   href="#"   onclick=window.parent.location.href=""></a>  
<a   href="#"   onclick=window.top.location.href=""></a>

 

posted @ 2020-05-30 07:44  就这个名字好  阅读(3124)  评论(0编辑  收藏  举报