I have a page on my site that uses an iframe, what i am doing is, if the user clicks any where in the iframe, they get a popup message:
alert('To learn more about this product please click on the \'Read More\' button.');
The code i put together is:
<div class="embed-responsive embed-responsive-16by9"><iframe class="embed-responsive-item" id="iframe" src="http://zzzzz.<?php echo $id; ?>.site2.net/" allowfullscreen></iframe></div>
<!-- Iframe -->
<script>
var monitor = setInterval(function(){
var elem = document.activeElement;
if(elem && elem.tagName == 'IFRAME'){
alert('To learn more about this product please click on the \'Read More\' button.');
clearInterval(monitor);
}
}, 100);
</script>
Currently the code does popup the message as expected, but only pops up once, if i try to re-click inside the iframe, there is no popups, am i missing something obvious? any help is appreciated.