Skip to content

Instantly share code, notes, and snippets.

@pcapelo
Forked from jaydson/gist:1780598
Created September 8, 2018 02:47
Show Gist options
  • Select an option

  • Save pcapelo/93a6a9ed3e6d5a030ea237dc002a3f8f to your computer and use it in GitHub Desktop.

Select an option

Save pcapelo/93a6a9ed3e6d5a030ea237dc002a3f8f to your computer and use it in GitHub Desktop.
How to detect a click event on a cross domain iframe
var myConfObj = {
iframeMouseOver : false
}
window.addEventListener('blur',function(){
if(myConfObj.iframeMouseOver){
console.log('Wow! Iframe Click!');
}
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){
myConfObj.iframeMouseOver = true;
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseout',function(){
myConfObj.iframeMouseOver = false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment