Friday, September 18, 2009

Passing information between parent and child window.

Had a problem in fixing a javascript scenario of passing information between parent and child window.

If you are going to assign a parent windows variable from child window, that variable has the assigned value , even if the child window is closed.

But if you try to assign an object like array or something in the child window, the assigned variable or object exists in the parent window only if the child window is still open. If the child window is closed , the variable becomes null.

It seems, in this case the parent variable just has the reference to the variable in the child window and not the exact values.

In my case , i want to pass array from child to parent window and i did in the following way.


function settingParentWindowVariable(obj)
{ if(obj.length>0)
{
for(var i=0;i
parentvariable[i] = obj[i];
}
}
}

I am not sure, whether it is the correct way of doing it.But it works in this case.

PS: There exists Tech post. Atleast to serve my bad memory.

No comments: