SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Play Youtube videos On a Embedded Player Upon clicking Multiple hyperlinks

    Hi guys.. I am just starting to learn JavaScript. I wanted to know how to have multiple hyperlinks (Containing links to Youtube Videos) that when clicked, cause the corresponding videos to play on the Youtube Player Embedded on the site. I hope my question is not too confusing. Thank you in advance!

    P.S.
    I saw some Source Code relating to this on StackOverflow and copied it and couldn't get it to work.. Here's my source code.

    Code HTML4Strict:
    <html>
    <head>
    <title> Sample Page </title>
    <script>
    // Get element holding the video (embed or object)
    var player = document.getElementById("MOVIE");
     
    //Create a simple function and check if player exists
    function play() {
        if(player) {
            player.playVideo();
        }
    }
    </script>
    </head>
    <body>
    <object width="420" height="315"><param name="MOVIE" value="http://www.youtube.com/v/HsQIoPyfQzM?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/HsQIoPyfQzM?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>
    </br></br>
    <a href="http://youtu.be/sPvqNMb4StI" onclick="play()"> THIS IS FIRST Video Link </a></br></br>
    <a href="http://youtu.be/w7_Ccu21QVs" onclick="play()"> THIS IS SECOND Video Link </a>
    </body>
    </html>

  2. #2
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any Kind souls out there to help me? =) Or is my question unclear?

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    something like this? http://sospets.brinkster.net/htmlpage2.htm
    if yes then just copy the source code thats all u need.

  4. #4
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That was exactly what I was looking for! Thank you so much Sir!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •