嗯,不能这样子//opener.document.form1.options[opener.document.form1.selectedIndex].text=id;不过,可以通过子窗口调用父窗口的方法..parent.htm<select name=sel>
<option value="1">Item1
<option value="2">Item2
</select>
<input type=button onclick="window.open('son.htm')" value="Open">
<script>
function add2()
{
var addoption2 = new Option("Text","Value");
var sel = document.all.sel;
sel.options[sel.options.length] = addoption2
}
function changeText(id)
{
var sel = document.all.sel;
sel.options[id].selected = true;
}
</script>son.htm<input type=button onclick="opener.add2()" value="ADD">
<input type=button onclick="opener.changeText(1)" value="ChangeSelected">
<option value="1">Item1
<option value="2">Item2
</select>
<input type=button onclick="window.open('son.htm')" value="Open">
<script>
function add2()
{
var addoption2 = new Option("Text","Value");
var sel = document.all.sel;
sel.options[sel.options.length] = addoption2
}
function changeText(id)
{
var sel = document.all.sel;
sel.options[id].selected = true;
}
</script>son.htm<input type=button onclick="opener.add2()" value="ADD">
<input type=button onclick="opener.changeText(1)" value="ChangeSelected">
解决方案 »
- 我想在网页中实现这样的效查,点“单词N",被点击的内容就变加粗加红,要怎么做?
- extjs4.0,TreePanel点击text时,checkbook也被勾选??急!!急!!
- <专题帖>内存泄漏
- 使前端获得CheckBox选中节点(TreeView)
- Javascript菜鸟求助!为什么程序没有反应?
- Response.Write alert还是有问题
- 谁能帮我解释下这句话的意思,很简单的JavaScript,
- iDiv.insertRow().insertCell(); 添加了一个 <tr><td></td></tr>,在用 innerHTML 给<td>赋值,怎样获得这是的<td>宽度?谢谢~~~
- 如何在JAVASCRIP中实现特定字符串替换?
- 如何将WSH(windows Scripting Host)应用于网页中?
- 请问层的ID中包含如"-"、"/"等字符的时候怎么办?
- 求救!在线等,关于密码验证
<html>
<head>
</head><body bgcolor="#FFFFFF">
<select id="select" style="width:200px">
<option>111</option>
<option>222</option>
<option>333</option>
<option>444</option>
<option>555</option>
</select>
<button onclick="window.open('a.html')">open</button></body>
</html>a.html
<html>
<body bgcolor="#FFFFFF">
<script language="JavaScript">
var id="555";
var obj = opener.document.all.select;
for(var i=0;i<obj.length;i++)
{
if(obj[i].text == id)
obj[i].selected = true;
}
self.close();
</script>
</body>
</html>