我试图在播放视频时暂停主页上的 slider ,这样它就不会一直滑动。看看here .
我试过在它上面添加一个 div
并捕获 div
的点击事件,但这不起作用。我想它只是将事件传递给 iframe
。请注意,iframe
正在从 Vimeo 加载内容,而不是从我的站点加载内容。
关于如何使这项工作有任何想法,或在播放视频时暂停 slider 的任何其他方式?我似乎走投无路...
最佳答案
在小型 iframe(例如 Facebook iframe)中检测点击的另一种方法是使用 mouseenter 和 mouseleave 事件。
<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;
});
关于jquery - 如何使用 jQuery for iframe 捕获点击事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5082623/