Subscribe on YouTube

Check out our videos on branding, web design, SEO, and online business.

How to Add Timestamps To Embedded YouTube Videos

In this video I will show you How to Add Timestamps To Embedded YouTube Videos.

The great thing about this code is you can use it on any type of website, so this isn’t just limited to WordPress websites. You can use this code anywhere you can enable Javascript on the page.

YouTube Javascript Code

				
					<div class="responsive-container"><div id="player"></div></div> <script>var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          videoId: 'S4cZjaXmuzE',
        });
      }
      function setCurrentTime(slideNum) {
        var object = [ 0, 133, 193 ];
        player.seekTo(object[slideNum]);
      }</script> 
				
			

HTML Code

				
					<strong>Timestamps:</strong>
<ul>
 	<li><a href="javascript:void(0);" onclick="setCurrentTime(0)">0:00 Intro</a></li>
 	<li><a href="javascript:void(0);" onclick="setCurrentTime(1)">2:13 1 Minute Challenge</a></li>
 	<li><a href="javascript:void(0);" onclick="setCurrentTime(2)">3:13 Website Speed Results</a></li>
</ul>
<input type="button" value="1 minute challenge" onclick="setCurrentTime(2)" />
				
			

CSS Code

				
					.responsive-container {
	position: relative;
	padding-bottom: 56.25%; /* 16:9 */
	padding-top: 0px;
	height: 0;
	overflow: hidden;
}

.responsive-container iframe,
.responsive-container object,
.responsive-container embed,
.responsive-container video
{
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}
				
			

Continue Reading...

Make your website work for you

Schedule Your Free Consultation