在一个页面〔这个页面中有一个<select>和一个文本框〕用window.open(........)打开了一个窗口,在这个窗口中引用window.opener.form1.t1.value="test"可以改变父窗口的文本框内容,但为什么不能给<select>加选项呢,这样写的window.opener.form1.selectTest.options.add(new Option('a','a'))//我试了好几种方法就是不行,IE提示“服务器出现错误”但在FireFox上正常!这个东西要用IE演示给别人看的,所以一定得在IE上起作用!但我在IE上的父窗口再加一个按钮,点它的事件这样写的“form1.selectTest.options.add(new Option('a','a')”它也能正常加入子选项,为什么在它打开的子窗口中就是不行呢!
2 回答
交互式爱情
TA贡献1712条经验 获得超3个赞
第一个页面:
<html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script>function addOption(){ form1.selectTest.options.add(new Option('a','a'));}</script></head><body> <form id="form1" name="form1"> <select name="selectTest" id="selectTest"></select> <input id="t1" name="t1"/></form> <button onclick="window.open('input.html')">click</button></body></html> |
第二个页面:
<!DOCTYPE html><html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head><body><input type="button" class="btn" value="确定" onclick="window.opener.addOption();"/></body></html> |
添加回答
举报
0/150
提交
取消
