找到你要的答案

Q:Multiple inputs leading to iframe javascript

Q:导致iframe javascript多输入

Is it possible to use multiple inputs, leading to the same iframe, but I need each input will show different content in the iframe, mainly like embedding things(such as youtube). Mainly, it's to switch between videos/songs, that would be my intention at least.

HTML:

<div align="left">
    <a><input id="mp3" title="YoutubeTitleOne" type="image" value="https://www.youtube.com/embed/(video1)" src="dot" alt="Submit" onclick="load()" height="21"></a>
    <a><input id="mp3" title="YoutubeTitleTwo" type="image" value="https://www.youtube.com/embed/(video2)" src="dot" alt="Submit" onclick="load()" height="21"></a>
</div>
<div id="mp3" style="height:350px;width:574px;background-color:#000000" align=
"center">
    <div><iframe id="play" src width="98.60%" height="310px" style="border:0px" align="center"></div>
</div>

JS:

function load() {
            document.getElementById("play").src = document.getElementById("mp3").value;
        }

可以使用多个输入,导致相同的iframe,但我需要每个输入都会显示在iframe内容不同,主要是嵌入的东西(如YouTube)。主要是,切换视频/歌曲,这将是我的意图至少。

HTML:

<div align="left">
    <a><input id="mp3" title="YoutubeTitleOne" type="image" value="https://www.youtube.com/embed/(video1)" src="dot" alt="Submit" onclick="load()" height="21"></a>
    <a><input id="mp3" title="YoutubeTitleTwo" type="image" value="https://www.youtube.com/embed/(video2)" src="dot" alt="Submit" onclick="load()" height="21"></a>
</div>
<div id="mp3" style="height:350px;width:574px;background-color:#000000" align=
"center">
    <div><iframe id="play" src width="98.60%" height="310px" style="border:0px" align="center"></div>
</div>

JS:

function load() {
            document.getElementById("play").src = document.getElementById("mp3").value;
        }
javascript  html  iframe