ONCLIK JQUERY for IFRAME does not work

Asked

Viewed 64 times

2

I make animated banners in Google Web Designer and use an IFRAME to call them on the page, I used a JQUERY code so that when clicked on top of IFRAME it would open another page but when I add 2 or 3 Bannes, having each its own website to open and functions with the different name, only works one banner, the others are without the function ONCLICK.

the code I used is this:

window.onload = function() {

    var oFrame = document.getElementById("FrameLateral");

    oFrame.contentWindow.document.onclick = function() {

    window.open('https://www.facebook.com/events/291519031247073/', '_blank');

    };

};

window.onload = function() {

    var oFrame = document.getElementById("myframe");

    oFrame.contentWindow.document.onclick = function() {

    window.open(' SITE ', '_blank');

    };

};

And in that case that would be IFRAME:

<center><iframe id="myframe" class="asd" src="http://127.0.0.1/CSS/animation/matanzafoz/index.html" frameborder="0" scrolling="no"></iframe></center><br>

and in another IFRAME:

    <center><iframe id="FrameLateral" class="asd" src="http://127.0.0.1/CSS/animation/novobanner/index.html" frameborder="0" scrolling="no"></iframe></center><br>
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.