Javascript 如何根据文本字段中的用户输入更改iframe URL?
我有一个iframe url,我想根据用户在文本字段中输入的内容进行更改。因此,我:Javascript 如何根据文本字段中的用户输入更改iframe URL?,javascript,html,forms,iframe,Javascript,Html,Forms,Iframe,我有一个iframe url,我想根据用户在文本字段中输入的内容进行更改。因此,我: <iframe src="http://player.twitch.tv/?channel={CHANNEL}" height="720" width="1280" frameborder="0" scrolling="no" allowfullscreen="true"> </iframe> 我想将{CHANNEL}更改为用户输入文
<iframe
src="http://player.twitch.tv/?channel={CHANNEL}"
height="720"
width="1280"
frameborder="0"
scrolling="no"
allowfullscreen="true">
</iframe>
我想将{CHANNEL}更改为用户输入文本字段并通过按钮提交的内容。例如,如果用户在文本字段中输入“TestName”,则新的iframe URL将变为src=”http://player.twitch.tv/?channel=TestName"
不知道怎么做。试试这个。请记住,输入未经验证/保护
函数更改通道(){
document.getElementById(“twitchFrame”).src=”http://player.twitch.tv/?channel=“+document.getElementById(“通道”).value;
}
换频道
您有代码吗?我们可以帮助您解决代码中的特定问题,但我们不会为您编写。您可以使用JavaScript事件来更改iframe的src属性。