Click to See Complete Forum and Search --> : accessing another window's functions


vccarvalho
12-22-2003, 10:37 AM
Hi there! I have a form in a window, that calls another window using the window.open method.
in the main window, I have a function called insertSelectElement(args) that receives 2 values, the index and the value for the select, those values comes from the child window. I'm, using this syntax in the child window:

window.opener.document.selectedIndex(value1, value2);

but it says that insertSelectedElement is not a function. what could be causing this?

Thanks

vinicius

pnaj
12-22-2003, 10:46 AM
You wrote ...

window.opener.document.selectedIndex(value1, value2);

... but did you mean ...

window.opener.document.insertSelectedElement(value1, value2);

vccarvalho
12-22-2003, 11:10 AM
yep, u'r right :)
sorry for that!

but even using the correct function name it does not work.

fredmv
12-22-2003, 05:04 PM
I'm guessing it isn't working because those are not methods of the document object; all functions are child objects of the window object. Therefore, in the child window, you could execute a function in the opener window like this:opener.selectedIndex(value1, value2);

vccarvalho
12-23-2003, 10:24 AM
Originally posted by fredmv
I'm guessing it isn't working because those are not methods of the document object; all functions are child objects of the window object. Therefore, in the child window, you could execute a function in the opener window like this:opener.selectedIndex(value1, value2);

That worked, thanks!! :D

fredmv
12-23-2003, 08:28 PM
You're welcome. ;)