I'm trying to make a watch page like the YouTube watch page.
Example of YouTube watch page URL: /watch?v=J3atcU_7yxA
Example of my watch page URL: /watch/?s=mindfield&e=isolation
I'm trying to achieve that with this JavaScript code:
var url = new URL(document.URL);
var s = url.searchParams.get("s");
var e = url.searchParams.get("e");
if (s == "mindfield" && e == "isolation") {
player('https://youtube.com/embed/iqKdEhx-dD4');
};
function player(source) {
document.getElementsByTagName("iframe")[0].setAttribute("src", source);
}
But it's just not working and I don't know why!
If you would like here is the website of where I'm trying to achieve that.
Thank you!