1. The child page is the situation where the parent page pops up through window.open
If a child page wants to pass a value to the parent page, just add window.opener in front of the document.
like:
1. Parent page code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled document title>
head>
<script language="javascript">
functiontanchu()
{
window.open("Untitled-5.html");
}
script>
<body>
<form id="form1" name="form1" method="post" action="">
<label> <input type="submit" name="button" id="button" value="Submit"
onclick="tanchu()" />
label> <label> <input type="text" name="textfield" id="textfield" />
label>
form>
</body>
</html>
2. Sub-page code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled document title>
head>
<script language="javascript">
function aaa()
{
window.opener.document.getElementByIdx('textfield').value='123123123';
}
script>
<body>
<form id="form1" name="form1" method="post" action="">
<label> <input type="submit" name="button" id="button" value="Submit"
onclick="aaa()" />
label>
form>
</body>
</html>
2. The subpage is the page situation in the iframe frame
If a child page wants to pass a value to the parent page, just add parent in front of the document.
1. Parent page code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled document title>
head>
<body>
<form id="form1" name="form1" method="post" action="">
<label> <input type="text" name="textfield" id="textfield" />
label>
<iframe id="myiframe" src="Untitled-3.html">iframe>
form>
</body>
</html>
2. Sub-page code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled document title>
head>
<script language="javascript">
function aa()
{
var a=parent.document.getElementByIdx('textfield').value;
alert(a);
}
script>
<body>
<form id="form1" name="form1" method="post" action="">
<label> <input type="submit" name="button" id="button" value="Submit"
onClick="aa()" />
label>
form>
</body>
</html>