该死的印度阿三,害我忙了半天……问题找到了,不能传引用类型的参数(在两个页面间)
opener
<script>
window.open("test2.htm")
function addoption(text, value)
{
var o = new Option(text, value)
document.form1.s1.add(o)
}
</script>
<form name="form1">
<select name="s1">
<option value="1">1</option>
</select>
<input type="text" value="t" name="t1">
</form>test2.htm
<script>
function adsel(){
window.opener.addoption(document.form2.t1.value, document.form2.t1.value)
}
</script>
<form name="form2">
<input type="text" name="t1">
<input type="button" onClick="adsel()">
</form>
opener
<script>
window.open("test2.htm")
function addoption(text, value)
{
var o = new Option(text, value)
document.form1.s1.add(o)
}
</script>
<form name="form1">
<select name="s1">
<option value="1">1</option>
</select>
<input type="text" value="t" name="t1">
</form>test2.htm
<script>
function adsel(){
window.opener.addoption(document.form2.t1.value, document.form2.t1.value)
}
</script>
<form name="form2">
<input type="text" name="t1">
<input type="button" onClick="adsel()">
</form>
opener有关系:父窗口:
<form name=form1>
<select name=parentList>
<option>请选择
</select>
</form>
<script language=javascript>
function writeParentList(str)
{
if(str=="") return;
if(document.form1.parentList)
{
e = document.form1.parentList;
var newOP=new Option(str, str, true, true);
for(var i=0; i<e.options.length; i++) //不重复
if(e.options[i].value == str) return;
e.options[e.options.length] = newOP;
}
}
</script><input type=button value=ok onclick="window.open('ttt.htm','meizz')">
子窗口:
<select onchange="if(window.name!='')opener.writeParentList(this.value)">
<option>请选择
<option value=aaa>aaa
<option value=bbb>bbb
<option value=ccc>ccc
<option value=ddd>ddd
<option value=eee>eee
</select>