I have an input function that accepts an iframe embed URL from the user is there any way to get the src from the input. For example: if user inputted <iframe width="1263" height="480" src="https://www.youtube.com/embed/KWFKabzKSxw" title="YouTube video player" frameborder="0" allowfullscreen></iframe> i want to extract the src that would be https://www.youtube.com/embed/KWFKabzKSxw and assign it to a new var. My current code is attached below. Any help is appreciated. Thanks in advance.
function input() {
globalThis.urlInput = "";
urlInput = prompt("Enter embed URL:");
if (urlInput == "") {
alert("No URL Inputted");
} else {
rename();
}
}
/*something like this but this wont work because urlInput is not an Id*/
function rename() {
var newUrl = document.getElementById(urlInput).src;
}
<button onclick="input()">Input1</button>