I'm using this solution to count clicks (on e.g facebook, twitter, ect. iframes).
Basically what it does is keep track of what iFrame people are hovering. Then if the window blurs that most likely means the user clicked the iframe banner.
If I click on another element inside the iframe, after I already clicked one, it won't count. I need to click somwhere on the website and back on the iframe to get click counted.
(e.g I click on facebook button, facebook window pops up, my click is counted. I close pop-up window, click on twitter button, my click is not counted unless I click somewhere on the page and the twitter button again)
I need to set focus back to main window somehow.
jQuery(document).ready(function() {
var overiFrame = -1;
jQuery('iframe#fb').hover(function() {
overiFrame = jQuery(this).closest();
}, function() {
overiFrame = -1
});
jQuery(window).blur(function() {
if(overiFrame != -1 ){
//do something
});