I am trying to get this so when I click inside an iframe whose source is from "site1.com" it shows an Alert. I did place the code after the iFrame and it does nothing. Here's my code: Code: <script type="text/javascript"> function showAlert(){ alert("iframe clicked"); } var elements = document.getElementsByTagName('iframe'); { if(elements.src.indexOf('site1.com') { elements.onfocus = showAlert(); } } </script> Code (markup): Thank you
not possible unless you can change what's inside the iframe. js doesn't permit it crossdomain for obvious security reasons