Skip to content

Instantly share code, notes, and snippets.

@Dobby89
Forked from jaydson/gist:1780598
Last active November 11, 2020 08:16
Show Gist options
  • Save Dobby89/b543cec9b97be6d16e9425989f1b7335 to your computer and use it in GitHub Desktop.
Save Dobby89/b543cec9b97be6d16e9425989f1b7335 to your computer and use it in GitHub Desktop.
How to detect a click event on a cross domain iframe
var iframeMouseOver = false;
window.addEventListener('blur',function(){
if(iframeMouseOver){
console.log('Wow! Iframe Click!');
}
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){
iframeMouseOver = true;
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseout',function(){
iframeMouseOver = false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment