I'm trying to pass the youtube URL to the embed src. It's working in Firefox but not IE or Chrome. Can someone please help me?

    <script>
    function videoplaying() {
    var myvideo = "http://www.youtube.com/v/2wBe3SDCcz8";
    var myEmbed = document.getElementById("myvideo");
    myEmbed.setAttribute("src", myvideo);
    return false;
    }
    </script>

    <a href="javascript:void(0)" onclick="videoplaying();">Video</a>

Recommended Answers

All 2 Replies

Post the html structure for 'myvideo'

Yep, need the code for 'myvideo'. Pretty sure the setAttribute is going to the wrong place as the src of YouTube videos are wrapped inside an iframe.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.