I'm developping a little extension for myself. The goal is simple, you click on the extension, you enter a youtube link, and the video is played inside your extension popup.
Here is my HTML
<body>
Youtube Link: <input type="text" id="link" name="firstname">
<button type="button" id="do-link"> Go ! </button>
<script src="popup.js"></script>
<p id="write">Here your link</p>
<iframe id="ytplayer" title="YouTube video player" class="youtube-player" type="text/html"
width="640" height="390" src="https://www.youtube.com/watch?v=DTqTs15Hc9w"
frameborder="0" allowFullScreen></iframe>
</body>
And my JS :
var a;
function link() {
a = document.getElementById('link').value;
document.getElementById('ytplayer').src = a;
console.log(a);
}
document.getElementById('do-link').onclick = link;
So this basically just print in the console what's inside my text box. And it displays a KSI video (or whichever video you want if you put hte link. I want to know if there's a simple way to replace the youtube links by the link written by the user in the text box ?