-2

I've got an HTML file that embeds a Youtube video using an iFrame. However before the video starts loading, I need to pass it an URL, since the iFrame just acts as a container.

Is it possible to do it with Javascript?.

Artemix
  • 8,497
  • 14
  • 48
  • 75

1 Answers1

1

Check this example if it's meeting your requirements

<iframe id="custom-frame" src="/test.html"></iframe>
<p>Click the button to change the value of the src attribute in the iframe </p>
<button onclick="changeFrame()">Try it</button>
<script>
      function changeFrame() {
        document.getElementById("custom-frame").src = "http://www.facebook.com";
      }
</script>

Hardik Pithva
  • 1,729
  • 1
  • 15
  • 31