[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

variable assignment from child window

I need to find out if something I'm doinging is considered an
acceptable JavaScript coding practice.

I've set up user registration for my home page that takes input on a
form in a child window called stat_window. Before opening the window I
create a property of stat_window called nav for accessing the main
Navigator window functions and properties with:


So far so good. The problem is this: From the child window I call 
a function in the nav window that needs to access the data that was 
just entered in the child window form. I don't want to change the 
function to accept arguments and pass the values unless absolutely 
necessary. What I have done is changed the values of two global 
variables (user_name and e_mail) in the Navigator window, from the 
child window with the following.

nav.user_name=<value from the form field>
nav.e_mail=<value from the form field>

This seems to work much of the time but when it doesn't, all hell
breaks loose. No GPFs or errors, just really squirrel bait results for
values of the two modified variables. At times they have equaled two
or three lines of code from my home page file. It's like a pointer is
getting knocked out of place (way out of place). At first I thought I
got a quote mis-positioned, but the results are too varied and 
sporadic for that.

Is it legitimate to directly assign a value to a variable in a different
window/file in this manner? And if it is, is there a trick to making
it reliable.

At this point I have changed the code to reassign the globals directly
after closing the child window by obtaining the stored value from the
cookie that is created in the registration process. I am not sure if
this does any good or not since I just put it in last night and the
error is on and off. My only assumtion in adding this code was that
maybe the values are not guaranteed after the child window is closed
(similar to certain conditions for returns in 'C').

If you want to look at the code the page is at:
Select the 'Personal User Stats' link.

Note: I have not included code to remove the cookie yet since I want 
to make sure the problem is solved before I add more code.

Anybody got any ideas? Thanks - John
For help about the list, please send a message to 'majordomo@obscure.org'
with the message body 'help'. To unsubscribe, send a message to
'majordomo@obscure.org' with the message body 'unsubscribe javascript'.
List archives and pointer to FAQ: http://www.obscure.org/javascript/