0

I have an iframe on a page (using advertisement in it). I am trying, when user visits, anywhere he clicked on webpage, it would open this advertisement in the new tab, like 123movies.to has. I also use cookies to show main div after 30 minutes. *NOTE: I use div green and block, iframe opacity=1, for test. Something like:

=----JQUERY----=

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#parent_popup').click(function(){
var $iframe = $("#iframe1").contents();
$iframe.click();   
});
});
</script>


<script language="javascript">
if (document.cookie.indexOf("visited") >= 0) {
} else {
var delay_popup = 500;
setTimeout("document.getElementById('parent_popup').style.display='block'", delay_popup);
expiry = new Date();
expiry.setTime(expiry.getTime()+(30*10*1000)); // 30 minutes
document.cookie = "visited=yes; expires=" + expiry.toGMTString();
}
</script>

=----CSS----=

<style>
#parent_popup {
background: green;
cursor:pointer;
display: none;
position: fixed;
z-index: 99999;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;}
</style>

=----HTML----=

<div id="parent_popup">
<iframe id="iframe1" style="opacity:1; filter: alpha(opacity=0)" marginwidth="0" marginheight="0" src="http://webpage.com/advertisement.html" frameborder="" height="100%" scrolling="NO" width="100%"></iframe>
</div>
david1928
  • 23
  • 5
  • 2
    You can't. Events related to iframe occur inside a different window created by the iframe and are not propagated to parent page window. If the iframe is from different domain you can not access inside it – charlietfl Apr 08 '17 at 15:34

1 Answers1

0

I think, this answer can help you https://stackoverflow.com/a/27369629/6072503

if not, please create an example, where I can test.

Community
  • 1
  • 1
SVANSKI
  • 426
  • 3
  • 13