This question has been asked a lot, and the answers are usually similar.
In basic terms, I need a function to perform when the contents of an iframe are clicked.
For the purposes of this demonstration, I have http://mydomain.com/iframe.html which contains an iframe with an ID of "iframeID" and a source of http://mydomain.com.
This code works:
jQuery(document).ready(function(){
$('#iframeID').contents().click(function(event) {
console.log('Clicked! ' + event.pageX + ' - ' + event.pageY);
});
});
But, this code only works in Internet Explorer. I need a solution that will work in all browsers.
The good news is, this is all on the same domain so if I need to put additional code in either the iframe source or my iframe.html then that's fine. I just need it to work cross-browser.
One other point to note, is I have a desire for this to work across subdomains.
I know it won't work with different domains, but as I understand it, subdomains should be fine? Any extra steps required for that to work?
Any help gratefully received!