How to capture click event with jQuery for iframe?

前端 未结 4 828
攒了一身酷
攒了一身酷 2020-12-10 18:28

I\'m trying to pause the slider on the homepage when a video is played so it doesn\'t keep sliding. Check it out here.

I\'ve tried adding a div on top o

4条回答
  •  不思量自难忘°
    2020-12-10 18:37

    Another method of detecting clicks in a small iframe, such as the Facebook iframe, is to use the mouseenter and mouseleave events.

    
    
    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/

提交回复
热议问题