1
votes

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>
4

4 Answers

3
votes

You could try something like this:

$(function() {
    $(window).load(function() {
        $('iframe').contents().find('body a.blue').click(function() {
            window.open(this.href);
            return false;
        });
    });
});
1
votes

Try putting <base target="_blank" /> into the <head> tag of the iframe page.

1
votes

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.

0
votes

Try this

window.parent.location = 'http://www.yourSite.com/mypage';