youtube iframe code example

Example 1: iframe autoplay

<!-- 
first add ?autoplay=1 to your video url
then add allow='autoplay' attribute to your iframe element
-->
<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1" allow='autoplay'></iframe>

Example 2: youtube embed video

//Author:Mohammad Arman Khan
<div>
       <iframe class="videoframe" src="https://www.youtube.com/watch?v=VfGW0Qiy2I0">
       </iframe>
</div>

Example 3: youtube in iframe opens youtube aoo

You can use "playsinline" parameter to play the video inline instead.

//Update Config.xml to include the follwing
<platform name="ios">
  <allow-navigation href="*://*youtube.com/*"/>
</platform>

Example 4: html5 iframe youtube loop

<iframe class="embed-responsive-item"id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/M7lc1UVf-VE?&autoplay=1&loop=1&rel=0&showinfo=0&color=white&iv_load_policy=3&playlist=M7lc1UVf-VE"
      frameborder="0" allowfullscreen></iframe>

Example 5: iframe youtube playlist not working html

<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PLQGSXoAiT2W4W8D3397nl4OB_GxfOmJk9" allowfullscreen></iframe>

Example 6: load youtube iframe player api

// This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

Tags:

Html Example