1.新建一个windows.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>windows窗口</title>
</head>
<body>
用户编号<input type="text" id="id"/><br/>
用户名字<input type="text" id="name"/><br/>
<input type="button" value="选择" onclick="userSelect()"/>
<script type="text/javascript">
function userSelect(){
window.open('user.html','','width=250,height=150');
}
</script>
</body>
</html>
2.运行效果如下
3.新建一个user.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户选择</title>
</head>
<body>
<table>
<tr>
<td><input type="button" value="选择" onclick="selectUser('001','小明')"></td>
<td>001</td>
<td>小明</td>
</tr>
</table>
<script type="text/javascript">
function selectUser(id,name){
var pwin=window.opener;
pwin.document.getElementById('id').value=id;
pwin.document.getElementById('name').value=name;
window.close();
}
</script>
</body>
</html>
4.在windows.html页面中,点击选择,可以进入user.html页面,效果如下
5.在user.html页面中点击选择,则可以把值传递到windows.html页面中