Skip to content

Instantly share code, notes, and snippets.

@dennyweiss
Forked from jaydson/gist:1780598
Created November 5, 2020 07:18
Show Gist options
  • Save dennyweiss/cc10dce6790a258447c3f9aeb368c2da to your computer and use it in GitHub Desktop.
Save dennyweiss/cc10dce6790a258447c3f9aeb368c2da 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