Click to See Complete Forum and Search --> : Parent window calling functions in a child page


jovialjonny
06-03-2003, 10:33 AM
Hi,
I've just realised I may have wasted a week's coding...
Is it possible for a parent window that has opened a child window via: var viewer = window.open("some url");
to then reference js functions contained in the child page?

I have a mehod in the page I just opened that I need to call from the parent in order to pass a variable, how can I do this? would something like:
viewer.addToViewer(theUrl)
be correct? (addToViewer is a function in the javascript file attached to the child page).

gil davis
06-03-2003, 10:44 AM
Originally posted by jovialjonny
would something like:
viewer.addToViewer(theUrl)
be correct?Yes, as long as the URL is in the same domain. Otherwise, you will get "Access Denied" or some other similar error.

Jona
06-03-2003, 10:44 AM
Yes, you should be able to call a function from the child window by using viewer.functionName();

Jona