admin管理员组文章数量:1356279
I have an iframe on a page and there is a link (on the same domain) I would like to open in a new physical window. When I use target="_blank", it just reloads the page in an iframe with the new one.
I also tried this JavaScript/jQuery code:
$(document).ready(function() {
$('a[target=_blank]').click(function() {
window.open(this.href);
return false;
})
});
With no success.
The HTML tag looks like this:
<a class="blue" href="/page/terms-of-service" target="_blank">Terms of Service</a>
I have an iframe on a page and there is a link (on the same domain) I would like to open in a new physical window. When I use target="_blank", it just reloads the page in an iframe with the new one.
I also tried this JavaScript/jQuery code:
$(document).ready(function() {
$('a[target=_blank]').click(function() {
window.open(this.href);
return false;
})
});
With no success.
The HTML tag looks like this:
<a class="blue" href="/page/terms-of-service" target="_blank">Terms of Service</a>
Share
Improve this question
edited Jun 15, 2013 at 20:56
Peter Mortensen
31.6k22 gold badges110 silver badges133 bronze badges
asked Sep 21, 2009 at 22:50
Richard KnopRichard Knop
83.8k154 gold badges398 silver badges561 bronze badges
0
4 Answers
Reset to default 3You could try something like this:
$(function() {
$(window).load(function() {
$('iframe').contents().find('body a.blue').click(function() {
window.open(this.href);
return false;
});
});
});
Try putting <base target="_blank" />
into the <head>
tag of the iframe page.
If your link really looks like this:
<a href="blah" target="_blank">some text</a>
...then barring something very unusual, any conforming browser will open the linked page in a new window (or new tab, on tabbed browsers with the "new window = new tab" feature turned on). If that's not happening, there's something specific to your page that's interfering with the normal process. If you post the actual link markup, we may be able to help you.
Try this
window.parent.location = 'http://www.yourSite./mypage';
本文标签: javascriptOpen in new window link in an iframeStack Overflow
版权声明:本文标题:javascript - Open in new window link in an iframe - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744018523a2576780.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论