Created
July 3, 2017 18:10
-
-
Save andrzj/9a3fd823d3a4a0d843ab0dc11ff9d7f9 to your computer and use it in GitHub Desktop.
Detect a click in 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
<iframe id="iframe" src="//example.com"></iframe> | |
<div id="message"></div> |
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 monitor = setInterval(function(){ | |
var elem = document.activeElement; | |
if(elem && elem.tagName == 'IFRAME'){ | |
message.innerHTML = 'Clicked'; | |
clearInterval(monitor); | |
} | |
}, 100); |
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
iframe { | |
width: 500px; | |
height: 300px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment