1. create a function in the parent窗口 to do the insertion2. try something likeparent.html:
<script language="javascript">
function addOption(sText,sValue)
{
var opt = new Option(sText,sValue);
document.form1.sel1.add(opt,0);
document.form1.sel1.selectedIndex = 0;
}
</script>
<form name="form1">
<select name="sel1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><iframe src="iframe.html"></iframe>iframe.html:
<script language="javascript">
function insertOption()
{
//parent.addOption("test1","test1");
var opt = new Option("test1","test1");
parent.document.form1.sel1.add(opt,0);
parent.document.form1.sel1.selectedIndex = 0;
}
</script><input type="button" value="add" onclick="insertOption()">
<script language="javascript">
function addOption(sText,sValue)
{
var opt = new Option(sText,sValue);
document.form1.sel1.add(opt,0);
document.form1.sel1.selectedIndex = 0;
}
</script>
<form name="form1">
<select name="sel1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><iframe src="iframe.html"></iframe>iframe.html:
<script language="javascript">
function insertOption()
{
//parent.addOption("test1","test1");
var opt = new Option("test1","test1");
parent.document.form1.sel1.add(opt,0);
parent.document.form1.sel1.selectedIndex = 0;
}
</script><input type="button" value="add" onclick="insertOption()">
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货