Skip to content

Instantly share code, notes, and snippets.

@presidenten
Forked from jaydson/gist:1780598
Created January 25, 2018 07:37
Show Gist options
  • Save presidenten/1225502cc0cd7dd4d5735af8fcb3891e to your computer and use it in GitHub Desktop.
Save presidenten/1225502cc0cd7dd4d5735af8fcb3891e 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