如何在iframe外部打开链接,将iframe源代码打开到新窗口

How to open link outside of iframe that opens iframe source into new window?

本文关键字:iframe 新窗口 窗口 源代码 外部 链接      更新时间:2023-09-26
<a href="//source of iframe name blah//" target="about:blank">open in new window</a>
<a href="1.html" target="blah">link 1</a>
<a href="2.html" target="blah">link 2</a>
<a href="3.html" target="blah">link 3</a>
<iframe name="blah" src="blah.html" ></iframe>

我有一个带有iframe的页面。我在iframe中有打开页面的链接,因此iframe不只有一个恒定的源。我希望有一个链接,将打开任何源是目前在iframe到一个新的窗口,无论是1.html, 2.html,或3.html等(更多的页面将不断添加,所以不会只有三个在未来)。

我该如何实现这个链接?提前谢谢你!: ~)

试试这个,

$(function(){
    $('a[target="blah"]').on('click',function(e){
       e.preventDefault();
       window.open(this.href,'blah');
    });
});