-
-
Save vidaaudrey/94d39955c6d4f0db22e6c1fe298b1a53 to your computer and use it in GitHub Desktop.
How to detect a click event on a cross domain iframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This works, but it does not trigger the actual click on the iframe itself.
How to trigger both (blur on parent and click on iframe) ?