代码如下:
父窗口: form.html
function addItems()
{
var AWnd=window.open('items.htm','fwId','resizable=yes,scrollbars=yes,width=300,height=400');
AWnd.focus();
}
function delItems()
{
var sel=document.menu.fwId;
for(i=0;i<=sel.options.length;i++)
{
if(sel.options[i]!=null)
if(sel.options[i].selected)
{
sel.options[i]=null;
i--;
}
}
}
</script>
<form method="post" name="menu">
<select name="fwId" size="5" multiple>
</select>
<input name="item" type="button" onClick="addItems()" value="Ìí¼Ó">
<input name="itemDel" type="button" onClick="delItems()" value="ɾ³ý" >
</form>
新开窗口items.html:
function doSubmit(value,name)
{
var aa = window.opener.document;
var myop = aa.createElement("OPTION");
for(var j = 0; j < aa.menu.fwId.options.length; j++)
{
if(value == aa.menu.fwId.options[j].value)
{
alert("ÒѾ±»Ñ¡Ôñ£¡");
return;
}
}
myop.text =name;
myop.value =value;
aa.menu.fwId.add(myop);
}
</script>
<form name="items">
<a onclick="javascript:doSubmit('1','test1');" href="#">test1</a><br>
<a onclick="javascript:doSubmit('2','test2');" href="#">test2</a><br>
</form>