Link of an Iframe opening in new tab?

3

Is there a possibility that when someone clicks on a link in an iframe this link opens in another tab?

Note: I do not have control of the html of the other page, so I can not put Blank in the link, it's content that is updated weekly so I need it in an iframe inside my page.

    
asked by anonymous 14.08.2015 / 22:46

1 answer

0

If the pages are in the same domain:

Yes, it is possible. Just add the target="_ blank" in all links. Example with JQuery:

$(document).ready(function () {
    $("iframe").load(function () {
        var iframe = document.getElementById("iframe")
        var anchors = iframe.contentDocument.getElementsByTagName("a");
        for (var i in anchors) {
            anchors[i].setAttribute("target", "_blank");
        }
    });
});

If they are in different domains:

The page can not be manipulated due to same origin security policy .

However you can do a trick, creating a proxy that makes a mirror of the original page in your domain. This can only be done with server-side languages.

    
16.08.2015 / 06:58