Web Analytics Made Easy -
StatCounter Accessing objects of the parent window - CodingForum

Announcement

Collapse
No announcement yet.

Accessing objects of the parent window

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing objects of the parent window

    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.

  • #2
    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) {.....

    Comment


    • #3
      Example Please

      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

      Comment


      • #4
        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;

        Comment


        • #5
          popup windows:-

          window.opener..

          frameset:-

          parent.framename..

          Comment


          • #6
            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...

            Comment


            • #7
              Field data returned successful!!

              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

              Comment


              • #8
                transfer value to a <div> on another window

                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].

                Comment


                • #9
                  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..

                  Comment

                  Working...
                  X