方法一
a1.jsp
<script type="text/javascript">
function openwin(){
//模式对话框,弹出后此页面就不可获得焦点
window.showModalDialog("index.jsp",window,"status:no;dialogHeight:210px;dialogWidth:360px;help:no");
//无模式对话框 window.showModelessDialog
}
function setValue(cid,cname){
document.getElementById("cid").value = cid;
document.getElementById("cname").value = cname;
}
</script>
</head>
<body>
<form name="form" action="" method="post">
客户 ID:<input type="text" name="cid" value="" id="cid" /><br />
客户名称:<input type="text" name="cname" value="" id="cname" /><br />
<input type="button" name="ok" value="请选择用户" οnclick="openwin()" />
</form>
</body>
<script>
function viewDate(cid,cname){
var sdate = window.dialogArguments;
//sdate表示的是另一个页面a1,window.dialogArguments中封装的是了另一个页面a1的信息
sdate.setValue(cid,cname); //调用a1中的函数
window.close();
}
</script>
</head>
<body>
<table border="1">
<tr>
<td>操作</td>
<td>客户id</td>
<td>客户名称</td>
</tr>
<tr>
<td><input type="button" value="选择" id="ss" οnclick="viewDate('001','深圳华为')"></td>
<td>001</td>
<td>深圳华为</td>
</tr>
<tr>
<td><input type="button" value="选择" οnclick="viewDate('002','用友软件')"></td>
<td>002</td>
<td>用友软件</td>
</tr>
</table>
</body>
方法二
使用window.open 方法 window.opener是对打开窗口的引用