How Would I Change The Src Of An Iframe With A Text Input?
So, Mojang released a version of Minecraft for the browser and I've been trying to add it to my website. I successfully did that with an iframe but people wanted multiplayer. Since
Solution 1:
Change the existing iframe source:
function changeIframe(url) {
document.getElementById('change').src = url;
}
Use the onchange
event instead of onsubmit
:
<input type="text" id="minecraftInput" onchange="changeIframe(this.value)" id="detroit" placeholder="https://classic.minecraft.net/?join=somelettersand#s" name="link" required>
Solution 2:
You mean this?
var url = $('#detroit').value;
$('iframe').setAttribute('src', url);
This will help you to add the url entered in the textbox to the iframe src. I tested it in your developer console of your website.
Post a Comment for "How Would I Change The Src Of An Iframe With A Text Input?"