【问题标题】:Remove iframe on scroll to a specific point滚动到特定点时删除 iframe
【发布时间】:2017-05-10 11:26:28
【问题描述】:

我需要在滚动到网站的特定点时删除 youtube iframe。这就是我到目前为止所做的。通过使用此脚本,我隐藏了包含 youtube iframe 但仍在播放视频的部分My website link

.rem{
display:none;
}

				
        <script>
			$(window).scroll(function() {    
    var scroll = $(window).scrollTop();
    var section1Height = $('#types-of-repair').offset().top + $('#types-of-repair').outerHeight() - window.innerHeight;
   if (scroll >= 3) {
       
        $(".about-section").addClass("rem"); 
       $(".clearHeader111").addClass("rem"); 
       
    }
 
     
   
});
    </script>
				<section class="about-section">
     <div class="pattern"></div>
               <div class="clearHeader1 video-background">
    <div class="clearHeader11 video-foreground">
    
      <iframe class="clearHeader111" src="https://www.youtube.com/embed/DEDS-bSHRfI?controls=1&showinfo=1&rel=0&autoplay=1&loop=1&&amp;ecver=1" frameborder="0" allowfullscreen></iframe>
    </div>
  </div>
  </section>

【问题讨论】:

    标签: javascript css html youtube-iframe-api


    【解决方案1】:

    也许这不是您想要的,但是;

    我会为其添加一个暂停触发器以停止播放音乐。

    我不能使用你的 sn-ps 来测试它,但是添加这样的东西应该可以工作。

    document.getElementByClassName('clearHeader111').iframe.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');

    您还可以通过将pauseVideo 替换为playVideo 来反转其效果

    【讨论】:

      猜你喜欢
      • 2012-04-22
      • 2013-03-06
      • 2013-11-30
      • 1970-01-01
      • 2013-12-13
      • 2011-05-26
      • 1970-01-01
      • 2011-09-06
      相关资源
      最近更新 更多