views:

391

answers:

2

I have an iframe on a page and there is a link I would like to open in a new physical window. When I use target="_blank" it just reloads the page in iframe with the new one.

I also tried this javascript:

$(document).ready(function() {
    $('a[target=_blank]').click(function() {
        window.open(this.href);
        return false;
    })
});

With no success.

HTML tag looks like this:

<a class="blue" href="/page/terms-of-service" target="_blank">Terms of Service</a>
+1  A: 

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.

T.J. Crowder
+1  A: 

Could try something like this -

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