I have designed a page containing my youtube videos. When you click on the title, embedded videos change on the right division. But the problem is url, I want users to share the video they want. If they press back button they can go back to previous video. I know we can have all these by html 5 history api, but I am new to this and after all my efforts I am not able to solve these problems. Please help.
Following is the code:
Youtube Videos Page
<style type="text/css">
body{
margin: 0px;
}
#leftdiv{
background-color: #A9F5D0;
float: left;
height:100%;
width: 30%;
}
#rightdiv{
background-color: #F8E0F1;
float: left;
height: 100%;
width: 70%;
}
#lectname{
padding:10px;
font-family: "comic sans ms";
}
</style>
<div id="container">
<div id="leftdiv">
<div id="lectname">
<p id="lectname1">Lec 01: What is Signal?</p>
<p id="lectname2">Lec 02: What is an Analog Signal?</p>
<p id="lectname3">Lec 03: What is Digital Signal?</p>
<p id="lectname4">Lec 04: Need of Digital Signal</p>
<p id="lectname5">Lec 05: Introduction to Digital Electronics</p>
<p id="lectname6">Lec 06: Switch and Bits Intuition</p>
</div>
</div>
<div id="rightdiv">
<iframe width="480" height="270" src="https://www.youtube.com/embed/M0mx8S05v60" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<script type="text/javascript">
var lectureVideos = {
lectname1: "https://www.youtube.com/embed/M0mx8S05v60",
lectname2: "https://www.youtube.com/embed/F5h3z8p9dPg",
lectname3: "https://www.youtube.com/embed/jRL9ag3riJY",
lectname4: "https://www.youtube.com/embed/izBaDRyqnBk",
lectname5: "https://www.youtube.com/embed/2xXErGeeb_Q",
lectname6: "https://www.youtube.com/embed/RF9I6UzI4Rc"
}
var videoLinks = document.getElementsByClassName("videoLink");
for(var i=0; i<videoLinks.length; i++){
videoLinks[i].onclick=function(){
document.getElementById("videoFrame").src=lectureVideos[this.id];
}
}
</script>