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>