PDA

View Full Version : Accessing objects of the parent window


rsmoore
06-26-2002, 09:29 PM
I have found the following web page which talks about opening a window and accessing it's properties at: http://wbabstract.com/javatutors/window5.shtml.

My problem is the following. I have a web page generated by an asp page which is not from an open statement. I want to open a popup (which I have working) and send the value of a radio button back to the original window. If the original window was not generated by an open statement, is there a way to assign the original window a name as in the example on the above site? I understand that the window.parent.document.form.field.value works only with frames and that the original page I am working with does not use frames.

If you can help, an example will provide a good mental picture.

adios
06-26-2002, 11:34 PM
Rachel...

Every window object has a .opener property; usually null, when the window in question has been spawned by JS (using window.open) it's set to a reference to the window (object) that ran the .open() method. You can name any window, any time (by setting its window[self/this/top].name property) but it shouldn't be necessary in this case. Test to be sure:

if (opener && !opener.closed) {.....

rsmoore
06-27-2002, 05:58 PM
I have the following field on a popup window form: document.AltMethod.method[i].value

By using your suggestion, how what is the code to be able to pass the value back to the program which called the popup?

Your help is greatly appreciated.

Rachel

tamienne
06-27-2002, 07:04 PM
well it depends on what you're going to do with the value after you pass it over.

You can pass it to a function in the parent window.

window.opener.functionName(document.AltMethod.method[i].value) can call a js function in your asp page.

or

window.opener.document.formName.inputField.value=document.AltMethod.method[i].value;

robertgamble
06-27-2002, 07:14 PM
popup windows:-

window.opener..

frameset:-

parent.framename..

adios
06-27-2002, 08:36 PM
Rachel...

An exact description of what the user input is, where the data (form control value) comes from, and where it needs to go to would help a lot...

rsmoore
06-27-2002, 09:21 PM
tamienne,

This worked beautifully!!

window.opener.document.formName.inputField.value=document.AltMethod.method[i].value;

That's exactly what I was looking for!

Thank you so much!

Rachel:)

jonathan
09-03-2002, 10:33 PM
Hi,
I'm trying to transfer a input value over to another window within a layer(<div>). It worked with Explorer 6 but I'm haveing some problems with Netscape 6.2 . I've been trying several different ways and none seem to work. Here's the one that works with Explorer.

for (var i=3;i<fieldsArray.length;i++){
eval("window.opener."+fieldsArray[1]+".document."+fieldsArray[2]+"."+fieldsArray[i]+".value = \""+argvalues[i-3]+"\"");

}

being fieldsArray[1] = div name
fieldsArray[2] = form name


When I run it in Netscape and check it in the console, it tells me that "window.opener.Step1 has no properties" Step one being fieldsArray[1].

adios
09-04-2002, 01:32 AM
Hard to believe that works in IE, either. An HTMLElement doesn't have a 'document' - window objects (and NS4 Layers) do. You alter element content using innerHTML (old way) or DOM methods.

Hard to be more specific witout knowing what all that stuff there refers to..