Html 如何在加载所有元素后播放youtube视频

Html 如何在加载所有元素后播放youtube视频,html,dom,Html,Dom,我在我的页面中加载YouTube视频,并在加载其他元素之前购买并播放。 所以页面加载速度变慢 <div class="wel_come_msg"> <div class="video_box"> <iframe width="100%" height="315" src="//www.youtube.com/embed/rDm7WstKG8s?autoplay=1" frameborder="0" allowfullscreen><

我在我的页面中加载YouTube视频,并在加载其他元素之前购买并播放。 所以页面加载速度变慢

<div class="wel_come_msg">
    <div class="video_box">
        <iframe width="100%" height="315" src="//www.youtube.com/embed/rDm7WstKG8s?autoplay=1" frameborder="0" allowfullscreen></iframe>
    </div>
</div>
将iframe更改为

<iframe id="video" width="100%" height="315" frameborder="0" allowfullscreen></iframe>

这将在页面加载时隐藏播放器所在的div 2秒钟

<script type = "text/javascript">  
    $(window).load(function() {
        setTimeout(function() {
            $("#contentPost").show('fadeIn', {}, 500)
        }, 2000);
    });
    </script>

    <style>
    .video_box { display:none;}
    </style>

    <div class="wel_come_msg">
        <div class="video_box">
            <iframe width="100%" height="315" src="//www.youtube.com/embed/rDm7WstKG8s?autoplay=1" frameborder="0" allowfullscreen></iframe>
        </div>
    </div>

在链接中看到autoplay=1?猜猜当您将其设置为0时会发生什么。类似问题;[有没有办法在我的网站上更快地加载嵌入式YouTube视频?][1][1]:@Banana:他想在页面加载后播放视频。当自动播放未设置时,不会happen@AugustusFrancis在这种情况下,我担心仅仅使用html是不够的。在DOM创建完成后,op必须使用javascript手动加载视频loaded@Banana是的,他似乎也不反对使用jQuery.no,这将在整个窗口的内容完全加载后2秒显示div。您可以跳过setTimeout并获得相同的结果。不过,op并没有要求使用jQuery解决方案,这不是jQuery,而是Javascript。第二,仅仅用html是不可能的。伙计,我甚至懒得和你争论。请了解jquery是什么。我包括了setTimeout,因为op没有指定在播放器之前没有加载哪个元素。他可以通过使用setTimout更好地把握时机。为了帮助你避免将来出现尴尬的情况,我将在这里留下这个链接,然后悄悄地退出
<script type = "text/javascript">  
    $(window).load(function() {
        setTimeout(function() {
            $("#contentPost").show('fadeIn', {}, 500)
        }, 2000);
    });
    </script>

    <style>
    .video_box { display:none;}
    </style>

    <div class="wel_come_msg">
        <div class="video_box">
            <iframe width="100%" height="315" src="//www.youtube.com/embed/rDm7WstKG8s?autoplay=1" frameborder="0" allowfullscreen></iframe>
        </div>
    </div>