用javascript实现父窗口与子窗体交互。

[b]父页代码[/b]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<html>
<head>
<title> new document </title>
</head>
<script language="javascript" >
function opennew(){
window.open("deplist.html","mywin", "menubar=no,width=400,height=500,resizeable=yes");

}

</script>
<body>
<form id="form1" >
Value:<input name="list" type="text" value="">
Text:<input name="dizhi" type="text" value="">
<input type="button" value="打开" onclick="opennew()">

</form>

</body>
</html>



子页代码
<html>
<head></head>
<script language="javascript">
function setValue(){

var depcode = depfrm.subdepart.options[depfrm.subdepart.selectedIndex].value;
var depname = depfrm.subdepart.options[depfrm.subdepart.selectedIndex].text;
//alert(depcode);
//alert(depname);
self.opener.document.all.form1.list.value=depcode;
self.opener.document.all.form1.dizhi.value=depname;

window.close();
}

</script>
</html>
<body>
<form id="depfrm" >
<table width="200px">
<tr>

<select name="subdepart" size="20" >
<option value="aaa">天涯</option>
<option value="aaa2">天涯2</option>
</select>
<br>
<input type="button" onclick="setValue()" value="确定">
</tr>
</table>
</form>
</body>

</html>



其中,父窗页面你随便命名好了。这里子窗页面是deplist.html
对效果没影响只是怕到时候有人打不开.&__&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值