Javascript 在iframe中的“在新窗口中打开”链接
我在一个页面上有一个iframe,我想在一个新的物理窗口中打开一个链接(在同一个域上)。当我使用target=“_blank”时,它只是在iframe中用新的页面重新加载页面 我还尝试了以下JavaScript/jQuery代码:Javascript 在iframe中的“在新窗口中打开”链接,javascript,jquery,html,Javascript,Jquery,Html,我在一个页面上有一个iframe,我想在一个新的物理窗口中打开一个链接(在同一个域上)。当我使用target=“_blank”时,它只是在iframe中用新的页面重新加载页面 我还尝试了以下JavaScript/jQuery代码: $(document).ready(function() { $('a[target=_blank]').click(function() { window.open(this.href); return false;
$(document).ready(function() {
$('a[target=_blank]').click(function() {
window.open(this.href);
return false;
})
});
没有成功
HTML标记如下所示:
<a class="blue" href="/page/terms-of-service" target="_blank">Terms of Service</a>
<a href="blah" target="_blank">some text</a>
$(function() {
$(window).load(function() {
$('iframe').contents().find('body a.blue').click(function() {
window.open(this.href);
return false;
});
});
});
如果您的链接看起来像这样:
<a class="blue" href="/page/terms-of-service" target="_blank">Terms of Service</a>
<a href="blah" target="_blank">some text</a>
$(function() {
$(window).load(function() {
$('iframe').contents().find('body a.blue').click(function() {
window.open(this.href);
return false;
});
});
});
…然后,除非出现非常不寻常的情况,否则any将在一个新窗口中打开链接页面(或在启用“new window=new tab”功能的选项卡浏览器上打开new tab)。如果没有发生这种情况,那么您的页面就有一些特定的东西干扰了正常的处理过程。如果您发布了实际的链接标记,我们可能会为您提供帮助。如果您的链接看起来像这样:
<a class="blue" href="/page/terms-of-service" target="_blank">Terms of Service</a>
<a href="blah" target="_blank">some text</a>
$(function() {
$(window).load(function() {
$('iframe').contents().find('body a.blue').click(function() {
window.open(this.href);
return false;
});
});
});
…然后,除非出现非常不寻常的情况,否则any将在一个新窗口中打开链接页面(或在启用“new window=new tab”功能的选项卡浏览器上打开new tab)。如果没有发生这种情况,那么您的页面就有一些特定的东西干扰了正常的处理过程。如果您发布实际的链接标记,我们可能会帮助您。您可以尝试以下方法:
<a class="blue" href="/page/terms-of-service" target="_blank">Terms of Service</a>
<a href="blah" target="_blank">some text</a>
$(function() {
$(window).load(function() {
$('iframe').contents().find('body a.blue').click(function() {
window.open(this.href);
return false;
});
});
});
您可以尝试以下方法:
<a class="blue" href="/page/terms-of-service" target="_blank">Terms of Service</a>
<a href="blah" target="_blank">some text</a>
$(function() {
$(window).load(function() {
$('iframe').contents().find('body a.blue').click(function() {
window.open(this.href);
return false;
});
});
});
尝试将
放入iframe页面的
标记中。尝试将
放入iframe页面的
标记中。尝试此操作
window.parent.location = 'http://www.yourSite.com/mypage';
试试这个
window.parent.location = 'http://www.yourSite.com/mypage';