子页面向父页面传值

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Parent</title>
</head>
<body>
<input id="Text1" type="text" />
<input id="Button1" type="button" value="Parent" onclick="window.open('children.htm')" />
</body>
</html>

child.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Child</title>
<script type="text/javascript">
function Open()
{
window.opener.document.getElementById(
"Text1").value=document.getElementById("Text2").value;
window.close();
}
</script>
</head>
<body>
<input id="Text2" type="text" />
<input id="Button2" type="button" value="Child" onclick="Open()" />
</body>
</html>

Parent.htm

你可能感兴趣的:(JavaScript,html,XHTML)