Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何根据文本字段中的用户输入更改iframe URL?_Javascript_Html_Forms_Iframe - Fatal编程技术网

Javascript 如何根据文本字段中的用户输入更改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 url,我想根据用户在文本字段中输入的内容进行更改。因此,我:

<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属性。