jonatec
asked on
Passing parameters from parent to child window using JS
Hi.
I am using IE9 and want to use JavaScript to pass parameters from a parent html page to a second child page.
I am calling from the parent using window.open('childPage.htm ') and getting the parent fiels values using window.opener.document.get ElementByI d('xxx').v alue in the child. This works fine.
However I have to open the child in the same window, so when I change the calling code to window.open('childPage.htm ','_self') I get an error at the child:
"Microsoft JScript runtime error: Unable to get value of the property 'document': object is null or undefined"
Any ideas please?
I am using IE9 and want to use JavaScript to pass parameters from a parent html page to a second child page.
I am calling from the parent using window.open('childPage.htm
However I have to open the child in the same window, so when I change the calling code to window.open('childPage.htm
"Microsoft JScript runtime error: Unable to get value of the property 'document': object is null or undefined"
Any ideas please?
<html>
<head>
<title></title>
<script type="text/javascript">
function fnGo() {
window.open('childPage.htm','_self');
}
</script>
</head>
<body>
<h3>PARENT</h3><p />
First Name: <input id='txtFirstName' name='txtFirstName' value='Fred'/><br />
Last Name: <input id='txtLastName' name='txtLastName' value='Smith'/><p />
<input type="button" value=" pass params " onclick="fnGo()" />
</body>
</html>
<html>
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$('document').ready(function () {
var FirstName = window.opener.document.getElementById('txtFirstName').value;
var LastName = window.opener.document.getElementById('txtLastName').value;
$('#labFirstName').text(FirstName);
$('#labLastName').text(LastName);
});
</script>
</head>
<body>
<h3>CHILD</h3>
First Name: <label id='labFirstName'></label><br />
Last Name: <label id='labLastName'></label>
</body>
</html>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks.
ASKER