父页面:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test
</title>
</head>
<body>
<input type="text" name="txtvalue" id="txtvalue">
<input type="text" name="bbbb" id="bbb" value="helloworld">
<input type="button" name="btnOpen" value="open" id="btnOpen" οnclick="aaa()"/>
</div>
</body>
<script language=javascript >
//var timer
var winOpen
function IfWindowClosed() {
if (winOpen.closed == true) {
document.getElementById("txtvalue").value="abcd";
//window.clearInterval(timer)
}
}
function aaa(){
document.getElementById("txtvalue").value=""
winOpen= window.open('page.html')
timer=window.setInterval("IfWindowClosed()",500);
}
</script>
</html>
弹出页面
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title></title>
<script>
window.opener.document.getElementById("bbb").value="xxx"
</script>
</head>
<body>
<h1>close me</h1>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test
</title>
</head>
<body>
<input type="text" name="txtvalue" id="txtvalue">
<input type="text" name="bbbb" id="bbb" value="helloworld">
<input type="button" name="btnOpen" value="open" id="btnOpen" οnclick="aaa()"/>
</div>
</body>
<script language=javascript >
//var timer
var winOpen
function IfWindowClosed() {
if (winOpen.closed == true) {
document.getElementById("txtvalue").value="abcd";
//window.clearInterval(timer)
}
}
function aaa(){
document.getElementById("txtvalue").value=""
winOpen= window.open('page.html')
timer=window.setInterval("IfWindowClosed()",500);
}
</script>
</html>
弹出页面
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title></title>
<script>
window.opener.document.getElementById("bbb").value="xxx"
</script>
</head>
<body>
<h1>close me</h1>
</body>
</html>