CodeChargenewbie
Posts: 114
|
| Posted: 01/28/2008, 6:07 AM |
|
I know how to refer to the parent window from the child? That's straight forward and there are numerous resources on the web on said topic. But what I am having trouble with is referring to child window datat from the parent window itself. Say I have a form control value on the child window; let's call it Child_control. How can I refer to this control in the parent's window javascript? Maybe I want to use alert to see its value or set its value to something, again, from inside the parent window. Is this possible to do???
This is what I have right now and it doesn't work. I defined a global javascript variable called test in the header of the child window and set it to a string value of "this works" (without quotes). So, it looks like this:
child window
-----------------
<html>
<head>
...
<script language="javascript" type="text/javascript">
var test = "this works";
</script>
I want to print this value from the parent window. Better yet, I'd like to change it's value from the parent window and then print it to confirm that the variable was set to something else.
This is what I have in the parent window that doesnt' seem to work:
parent window
--------------------
//inside of a function call
var win;
win = window.open("PopUptest.php", "Test", "height=240, width = 320, toolbar=no, scrollbars=yes, menubar=no");
win.focus();
//Up to here, it opens, focuses, and works fine
alert(win.test); // tells me "undefined" (without quotes)
What am I doing wrong here? Nevermind trying to manipulate a child's form control from the parent window. I just want to print the child's global javascript variable from the parent window. There must be a way to do this.
Thank you.
|