How to capture click event with jQuery for iframe?

I am trying to pause the slider on the main page when playing a video so that it does not move. Check here .

I tried adding divon top of it and fixing the click events for div, but this will not work. It just conveys events to iframe, I suppose. Please note that it iframedownloads content from Vimeo, not from my site.

Any ideas on how to make this work, or any other way to pause the slider while playing a video? I seem to be at a dead end without options ...

+5
source share
4 answers

It seems that it would be easier to use the Vimeo API to register events released by the player.

An example can be found here: https://github.com/vimeo/vimeo-api-examples/blob/master/moogaloop-api/javascript/froogaloop.html

Documentation: http://vimeo.com/api/docs/moogaloop

IN ACTION: http://jsfiddle.net/u5jG6/

+2
source

Another method for detecting clicks in a small iframe, such as a 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&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;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/

+3
source

click iFrame, . , , , iframe, , . , , Vimeo.

<div class="item">
<iframe src="http://player.vimeo.com/video/20183913?title=0&amp;byline=0&amp;portrait=0" width="612" height="344" frameborder="0"></iframe>
</div>

<script type="text/javascript">
$("div.item iframe")
.mouseover(function(){
    alert("Pause animation");
})
.mouseout(function(){
    alert("Play animation");
});
</script>

http://jsfiddle.net/r8guJ/

+2

jQuery: https://github.com/finalclap/iframeTracker-jquery.

vimeo player iframe jQuery , ( - ):

jQuery(document).ready(function($){
    $('.vimeo_player iframe').iframeTracker({
        blurCallback: function(){
            // Stop your slider
        }
    });
});
+1

All Articles