Another method of detecting clicks in a small iframe, such as the Facebook iframe, is to use the mouseenter and mouseleave events.
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fisthegovernmentopen.info%2F&layout=button_count&show_faces=false&width=100&action=like&font=verdana&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowtransparency="true"></iframe>
var inIframe = false;
$('iframe[src^="http://www.facebook.com"]')
.bind('mouseover', function(){
console.log('entered iframe');
inIframe = true;
setTimeout(function() {
if ( inIframe ) { console.log('clicked on iframe'); }
}, 1000);
})
.bind('mouseout', function(){
console.log('left iframe');
inIframe = false;
});
http://jsfiddle.net/gQzeA/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…