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';