Load entire page when clicking link within Iframe

0

Hello,

I have an Iframe as follows:

<iframe width="230" height="280" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://impressoearte.com/produto-em-destaque/"target="_top" ></iframe>    

What I want to do:

This iframe calls the product of a specific page within a part of the main site, the page specifies this: link

This product contains a link in the image to view more details of this product. I need that by clicking on this product image the main page will be loaded onto the product page and not just the block that the iframe is in. I need a solution that does not need to know the link that will be in the product image, that is, regardless of the link of the image of the product the loading is done.

Can anyone help me?

    
asked by anonymous 01.07.2016 / 01:29

1 answer

2

If you have access to the HTML code of the page in question, the solution is quite simple. Just add a target attribute to the link with value _blank which in this case you open the link on another page:

<a href="http://impressoearte.com/produto-em-destaque/" target="_blank">
    <img src="http://impressoearte.com/wp-content/uploads/2016/06/exaustor-510x510.jpg"/></a>

Butifyouwanttoopenit,justuse _parent :

<a href="http://impressoearte.com/produto-em-destaque/" target="_parent">
   <img src="http://impressoearte.com/wp-content/uploads/2016/06/exaustor-510x510.jpg"/></a>

Youcanstilltrywithjavascript:

<a href="http://impressoearte.com/produto-em-destaque/" onclick="return irParaPaginaAcima(this.href)">
   <img src="http://impressoearte.com/wp-content/uploads/2016/06/exaustor-510x510.jpg"/></a><scripttype="text/javascript">
    var irParaPaginaAcima = function irParaPaginaAcima (link) {
        window.parent.location = link;
        return false;
    }
</script>

In newer browsers, none of this will work if you do not allow it. To do this you need to set the attribute sandbox in iframe with the value corresponding to what you want to release .

<!-- Para habilitar a navegação por target="_parent" -->
<iframe sandbox="allow-top-navigation" ... />


<!-- Para habilitar a navegação por javascript (window.location = url) -->
<iframe sandbox="allow-scripts" ... />

I hope I have helped \ o /

    
01.07.2016 / 02:55