play youtube iframe javascript code example
Example 1: youtube embed video
//Author:Mohammad Arman Khan
<div>
<iframe class="videoframe" src="https://www.youtube.com/watch?v=VfGW0Qiy2I0">
</iframe>
</div>
Example 2: 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);