使用下拉菜单在 iframe 中打开外部 link

Open external link in iframe using drop down menu

我正在使用php读取文本文件并生成下拉菜单,该下拉菜单将在选择选项

时在新选项卡中打开link
<select onChange="window.location.href=this.value">
<?php
if ($file = @fopen('data-receive.txt', 'r')) {
while(($line = fgets($file)) !== false) {
echo "<option style='width:100px;' value='http://{$line}'>{$line}</option>";
}
fclose($file);
}
?>
</select>

这非常有效,可以在新选项卡中打开所选网站。

但是,我在页面上有一个 iframe,我希望下拉菜单选项在 iframe 中打开,而不是在新选项卡中打开

<iframe src="demo.html" name="test-frame" width="100%" height="500px"></iframe>

这可能吗? 任何帮助将不胜感激或 sms

** 已解决 ** 我改变了

window.href.location 

frames['test-frame'].location.href

来源: http://konus.biz/books/DHTML/%D3%F7%E5%E1%ED%E8%EA%20JS%20%EE%F2%20quirksmode/iframe.html#

<select id="changeIframe">
<?php
if ($file = @fopen('data-receive.txt', 'r')) {
while(($line = fgets($file)) !== false) {
echo "<option style='width:100px;' value='http://{$line}'>{$line}</option>";
}
fclose($file);
}
?>
</select>

Ifarm:

<iframe id="sourceIframe" src="demo.html" name="test-frame" width="100%" height="500px"></iframe>

Javascript:

var iframe = document.getElementById("sourceIframe");
var changeIframe= document.getElementById("changeIframe");

changeIframe.onchange = function()
{
    iframe.src = this.value;
}