bobyk123
asked on
communication between two browsers
hi,
I have a problem. I need to communicate between a parent window and the child window and viceversa. (i.e) I need to pass parameters from one window to another.
I tried but was unsuccessful.
Is it possible?
If so can u please give me the code for that.
I have a problem. I need to communicate between a parent window and the child window and viceversa. (i.e) I need to pass parameters from one window to another.
I tried but was unsuccessful.
Is it possible?
If so can u please give me the code for that.
ASKER
thanks for the reply. searlas your answer is working
but in addition i need to close the child window after the parameters are sent to the parent window
hope i will get the reply quickly.
but in addition i need to close the child window after the parameters are sent to the parent window
hope i will get the reply quickly.
In the example above, you would just change the method that the child window is calling...
function parentMethod(parentVal) {
document.getElementById("v ar").inner HTML = parentVal;
child.close(); // close child window
child = null; // remove reference
}
function parentMethod(parentVal) {
document.getElementById("v
child.close(); // close child window
child = null; // remove reference
}
ASKER
can i pass array from a window to another?
if so, how can it be done
if so, how can it be done
As shown above:
// change value of javascript val on child
child['someVal'] = "parents rule";
substitute an array for "parents rule";
var localArray = new Array(....);
child['someVal'] = localArray;
// change value of javascript val on child
child['someVal'] = "parents rule";
substitute an array for "parents rule";
var localArray = new Array(....);
child['someVal'] = localArray;
ASKER
the array has to be passed from child window to parent window
It's the same... replace child with opener...
opener['someVal'] = localArray;
opener['someVal'] = localArray;
ASKER
I tried that by replacing but i am getiing error
I declared an array with 5 elements in it. and passed the array to the parent. but i am getting the following error.
the error is :
in parent window it is "object dossent support this property or method"
in the child window it is "object expected"
I declared an array with 5 elements in it. and passed the array to the parent. but i am getting the following error.
the error is :
in parent window it is "object dossent support this property or method"
in the child window it is "object expected"
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 searlas for answering ny questions
the array values are being passed from child to parent browser
once again thanks for your support.
the array values are being passed from child to parent browser
once again thanks for your support.
ASKER
thanks searlas for answering ny questions
the array values are being passed from child to parent browser
once again thanks for your support.
the array values are being passed from child to parent browser
once again thanks for your support.
parent.html:
<html>
<head>
<script type="text/javascript">
var child = null;
function openChild() {
child = window.open("child.html", "child");
}
function hiKid() {
if (child && !child.closed) {
// DOM manipulation
child.document.getElementB
// change value of javascript val on child
child['someVal'] = "parents rule";
// call method on child
child['childMethod']();
}
}
// called from child frame
function parentMethod(parentVal) {
document.getElementById("v
}
</script>
</head>
<body onLoad="openChild();setTim
Message from child: <b><span id="marker"></span></b><br
Value set by child: <i><span id="var"></span></i>
</body>
</html>
child.html
<html>
<head>
<script type="text/javascript">
function helloDad() {
if (opener != null && !opener.closed) {
opener.document.getElement
// call method on parent, with parameter
opener['parentMethod']('pa
}
}
var someVal = 0;
function childMethod() {
document.getElementById("v
}
</script>
</head>
<body onLoad="helloDad()">
Message from parent: <b><span id="marker"></span></b><br
Value set by parent: <i><span id="varSpan"></span></i>
</body>
</html>