Links with Iframes

3

Good, I need through iframes, show information from a blog, I built 3 iframes that are showing the latest news, The problem is that I had to do so, because the page is totally different to the blog, because the blog is of Wordpress, and I do not have access to the code, The problem is that I want the person to click on the link that is inside the IFRAME, appear in another tab, since it loads within the same iframe and breaks the design of the page

<iframe style="margin-left:150px" src="https://inglesencasablogblog.wordpress.com/#post-380t" scrolling="no" width="800" height="300"></iframe>
    <iframe style="margin-left:150px" src="https://inglesencasablogblog.wordpress.com/#post-345" scrolling="no" width="800" height="300"></iframe>
    <iframe style="margin-left:150px" src="https://inglesencasablogblog.wordpress.com/#post-360" scrolling="no" width="800" height="300"></iframe>

That's what happens when I click on the link in the IFRAME

    
asked by Carlos Estarita 18.12.2016 в 18:22
source

3 answers

1

If you do not have access to the code of the pages you are using in the iframes I would recommend that you try another approach (although it has more work). It would be, if possible, that you access the content of blogs via RSS (for example), so you are the one who paints the content as you want and you give the behavior you want.

    
answered by 23.12.2016 в 12:24
0

If you want any link of your iframe to be opened in a tab, you must add the attribute target="_ blank"

Example:

<a href="https://inglesencasablogblog.wordpress.com/acerca-de/" target="_blank" >SOBRE NOSOTROS
</a>
    
answered by 18.12.2016 в 18:56
0

You can do the following:

Replace target='blank' with onclick='window.open();'

You can also use

<a target="_parent" href="http://url.org">link</a>

If you do not have access, what I imagine, is that you can do:

Jquery

$(document).ready(function () {
            $("#iframe").load(function () {
                var ifr = document.getElementById("iframe")
                var anchors = ifr.contentDocument.getElementsByTagName("a");
                for (var i in anchors) {
                    anchors[i].setAttribute("target", "_blank");
                }
            });
        });
    
answered by 18.12.2016 в 18:42