submiting to a parent window from a popup child window?

Discussion in 'Javascript' started by midnight_use_only@yahoo.com, Jun 11, 2006.

  1. Guest

    hi all,
    quick question, how do you submit a form to a parent window from a
    child popup window? i have the following and all online documentation
    *suggests* that it should work but it does NOT:

    // Parent window:
    <script language="JavaScript">
    function popup(url, name)
    {
    window.open(url, name, "width=800,height=600,scrollbars=yes");
    return false;
    }
    </script>
    ....
    <form name=form1 method=post action=something.php>
    <input type=hidden name=h1 value='' >
    <a href="#"
    target="childWindowName" onclick="return popup('url.php','Some
    name');">Pop</a>
    ....
    </form>

    // Now in the child popup window
    <script language="JavaScript">
    function handleSubmit(aValue)
    {
    var myParent = opener.document.forms.form1;
    myParent.h1.value=aValue;
    myParent.submit(); // ERROR: Object doesn't support this property
    or method
    return true;
    }
    </script>
    <a href=# onclick="handleSubmit(2006);">Submit</a>

    i have spent a few hours searching online and all the examples
    indicates that this example should work but it doesn't, not in IE or
    FF. in FF, nothing happen and in IE, the following error show up:

    Object doesn't support this property or method

    any idea? thanks!
    , Jun 11, 2006
    #1
    1. Advertising

  2. Guest

    anyone? any idea?

    wrote:
    > hi all,
    > quick question, how do you submit a form to a parent window from a
    > child popup window? i have the following and all online documentation
    > *suggests* that it should work but it does NOT:
    >
    > // Parent window:
    > <script language="JavaScript">
    > function popup(url, name)
    > {
    > window.open(url, name, "width=800,height=600,scrollbars=yes");
    > return false;
    > }
    > </script>
    > ...
    > <form name=form1 method=post action=something.php>
    > <input type=hidden name=h1 value='' >
    > <a href="#"
    > target="childWindowName" onclick="return popup('url.php','Some
    > name');">Pop</a>
    > ...
    > </form>
    >
    > // Now in the child popup window
    > <script language="JavaScript">
    > function handleSubmit(aValue)
    > {
    > var myParent = opener.document.forms.form1;
    > myParent.h1.value=aValue;
    > myParent.submit(); // ERROR: Object doesn't support this property
    > or method
    > return true;
    > }
    > </script>
    > <a href=# onclick="handleSubmit(2006);">Submit</a>
    >
    > i have spent a few hours searching online and all the examples
    > indicates that this example should work but it doesn't, not in IE or
    > FF. in FF, nothing happen and in IE, the following error show up:
    >
    > Object doesn't support this property or method
    >
    > any idea? thanks!
    , Jun 12, 2006
    #2
    1. Advertising

  3. Seige Guest

    First things first, both your pages (parent and child) must be under
    the same domain and/or path. If this is the case then it could be that
    you gave the window wrong names...

    > > <form name=form1 method=post action=something.php>
    > > <input type=hidden name=h1 value='' >
    > > <a href="#"
    > > target="childWindowName" onclick="return popup('url.php','Some
    > > name');">Pop</a>
    > > ...
    > > </form>


    where does childWindowName reference to? is it necessary for it to be
    there?

    'Some name' shouldn't have any spaces in between, so you might want to
    consider 'Some_name'

    otherwise you could try the onsubmit attribute in form1



    wrote:
    > anyone? any idea?
    >
    > wrote:
    > > hi all,
    > > quick question, how do you submit a form to a parent window from a
    > > child popup window? i have the following and all online documentation
    > > *suggests* that it should work but it does NOT:
    > >
    > > // Parent window:
    > > <script language="JavaScript">
    > > function popup(url, name)
    > > {
    > > window.open(url, name, "width=800,height=600,scrollbars=yes");
    > > return false;
    > > }
    > > </script>
    > > ...
    > > <form name=form1 method=post action=something.php>
    > > <input type=hidden name=h1 value='' >
    > > <a href="#"
    > > target="childWindowName" onclick="return popup('url.php','Some
    > > name');">Pop</a>
    > > ...
    > > </form>
    > >
    > > // Now in the child popup window
    > > <script language="JavaScript">
    > > function handleSubmit(aValue)
    > > {
    > > var myParent = opener.document.forms.form1;
    > > myParent.h1.value=aValue;
    > > myParent.submit(); // ERROR: Object doesn't support this property
    > > or method
    > > return true;
    > > }
    > > </script>
    > > <a href=# onclick="handleSubmit(2006);">Submit</a>
    > >
    > > i have spent a few hours searching online and all the examples
    > > indicates that this example should work but it doesn't, not in IE or
    > > FF. in FF, nothing happen and in IE, the following error show up:
    > >
    > > Object doesn't support this property or method
    > >
    > > any idea? thanks!
    Seige, Jun 12, 2006
    #3
  4. Guest

    comments below...

    Seige wrote:
    > First things first, both your pages (parent and child) must be under
    > the same domain and/or path. If this is the case then it could be that
    > you gave the window wrong names...


    yes the parent and the child window are under the same domain and same
    path.

    >
    > > > <form name=form1 method=post action=something.php>
    > > > <input type=hidden name=h1 value='' >
    > > > <a href="#"
    > > > target="childWindowName" onclick="return popup('url.php','Some
    > > > name');">Pop</a>
    > > > ...
    > > > </form>

    >
    > where does childWindowName reference to? is it necessary for it to be
    > there?


    it's not referenced anywhere. correct me if i am wrong (most likely),
    target="childWindowName" is the name of the child window and is
    required for a popup right? otherwise, i could have use something like
    target=_blank

    >
    > 'Some name' shouldn't have any spaces in between, so you might want to
    > consider 'Some_name'


    actually, it doesn't have space in the actual code. iti's my mistake to
    have a space here

    >
    > otherwise you could try the onsubmit attribute in form1
    >


    i suppose i could do that but i am more interested to find out why my
    solution doesn't work in the first place where all online documentation
    and code example suggests that it should. i think you are on the right
    track that i must have some sort of name-reference thing mess up
    between the child and the parent window but the thing is i can get a
    reference of the parent window and setting hidden field variables and
    such, it's just the submit() method keep saying it's not support

    >
    >
    > wrote:
    > > anyone? any idea?
    > >
    > > wrote:
    > > > hi all,
    > > > quick question, how do you submit a form to a parent window from a
    > > > child popup window? i have the following and all online documentation
    > > > *suggests* that it should work but it does NOT:
    > > >
    > > > // Parent window:
    > > > <script language="JavaScript">
    > > > function popup(url, name)
    > > > {
    > > > window.open(url, name, "width=800,height=600,scrollbars=yes");
    > > > return false;
    > > > }
    > > > </script>
    > > > ...
    > > > <form name=form1 method=post action=something.php>
    > > > <input type=hidden name=h1 value='' >
    > > > <a href="#"
    > > > target="childWindowName" onclick="return popup('url.php','Some
    > > > name');">Pop</a>
    > > > ...
    > > > </form>
    > > >
    > > > // Now in the child popup window
    > > > <script language="JavaScript">
    > > > function handleSubmit(aValue)
    > > > {
    > > > var myParent = opener.document.forms.form1;
    > > > myParent.h1.value=aValue;
    > > > myParent.submit(); // ERROR: Object doesn't support this property
    > > > or method
    > > > return true;
    > > > }
    > > > </script>
    > > > <a href=# onclick="handleSubmit(2006);">Submit</a>
    > > >
    > > > i have spent a few hours searching online and all the examples
    > > > indicates that this example should work but it doesn't, not in IE or
    > > > FF. in FF, nothing happen and in IE, the following error show up:
    > > >
    > > > Object doesn't support this property or method
    > > >
    > > > any idea? thanks!
    , Jun 12, 2006
    #4
  5. Seige Guest

    Hmm... i'm clueless as to why this happen. Usually when something like
    this happens, I would regard it as another "Browser-Securit-Issue" and
    proceed with the workaround. (aka onsubmit)



    wrote:
    > comments below...
    >
    > Seige wrote:
    > > First things first, both your pages (parent and child) must be under
    > > the same domain and/or path. If this is the case then it could be that
    > > you gave the window wrong names...

    >
    > yes the parent and the child window are under the same domain and same
    > path.
    >
    > >
    > > > > <form name=form1 method=post action=something.php>
    > > > > <input type=hidden name=h1 value='' >
    > > > > <a href="#"
    > > > > target="childWindowName" onclick="return popup('url.php','Some
    > > > > name');">Pop</a>
    > > > > ...
    > > > > </form>

    > >
    > > where does childWindowName reference to? is it necessary for it to be
    > > there?

    >
    > it's not referenced anywhere. correct me if i am wrong (most likely),
    > target="childWindowName" is the name of the child window and is
    > required for a popup right? otherwise, i could have use something like
    > target=_blank
    >
    > >
    > > 'Some name' shouldn't have any spaces in between, so you might want to
    > > consider 'Some_name'

    >
    > actually, it doesn't have space in the actual code. iti's my mistake to
    > have a space here
    >
    > >
    > > otherwise you could try the onsubmit attribute in form1
    > >

    >
    > i suppose i could do that but i am more interested to find out why my
    > solution doesn't work in the first place where all online documentation
    > and code example suggests that it should. i think you are on the right
    > track that i must have some sort of name-reference thing mess up
    > between the child and the parent window but the thing is i can get a
    > reference of the parent window and setting hidden field variables and
    > such, it's just the submit() method keep saying it's not support
    >
    > >
    > >
    > > wrote:
    > > > anyone? any idea?
    > > >
    > > > wrote:
    > > > > hi all,
    > > > > quick question, how do you submit a form to a parent window from a
    > > > > child popup window? i have the following and all online documentation
    > > > > *suggests* that it should work but it does NOT:
    > > > >
    > > > > // Parent window:
    > > > > <script language="JavaScript">
    > > > > function popup(url, name)
    > > > > {
    > > > > window.open(url, name, "width=800,height=600,scrollbars=yes");
    > > > > return false;
    > > > > }
    > > > > </script>
    > > > > ...
    > > > > <form name=form1 method=post action=something.php>
    > > > > <input type=hidden name=h1 value='' >
    > > > > <a href="#"
    > > > > target="childWindowName" onclick="return popup('url.php','Some
    > > > > name');">Pop</a>
    > > > > ...
    > > > > </form>
    > > > >
    > > > > // Now in the child popup window
    > > > > <script language="JavaScript">
    > > > > function handleSubmit(aValue)
    > > > > {
    > > > > var myParent = opener.document.forms.form1;
    > > > > myParent.h1.value=aValue;
    > > > > myParent.submit(); // ERROR: Object doesn't support this property
    > > > > or method
    > > > > return true;
    > > > > }
    > > > > </script>
    > > > > <a href=# onclick="handleSubmit(2006);">Submit</a>
    > > > >
    > > > > i have spent a few hours searching online and all the examples
    > > > > indicates that this example should work but it doesn't, not in IE or
    > > > > FF. in FF, nothing happen and in IE, the following error show up:
    > > > >
    > > > > Object doesn't support this property or method
    > > > >
    > > > > any idea? thanks!
    Seige, Jun 12, 2006
    #5
  6. Guest

    unfortunetly, onsubmit() won't work too because the form is not
    submited so the event is never trigger. i did solve this prolbme by
    using this:

    // myParent.submit(); -- does NOT work
    myParent.mySubmitButton.click(); // this does work

    by using the click() event, it does exactly what i need. i still have
    no idea why submit() doesn't work.

    Seige wrote:
    > Hmm... i'm clueless as to why this happen. Usually when something like
    > this happens, I would regard it as another "Browser-Securit-Issue" and
    > proceed with the workaround. (aka onsubmit)
    >
    >
    >
    > wrote:
    > > comments below...
    > >
    > > Seige wrote:
    > > > First things first, both your pages (parent and child) must be under
    > > > the same domain and/or path. If this is the case then it could be that
    > > > you gave the window wrong names...

    > >
    > > yes the parent and the child window are under the same domain and same
    > > path.
    > >
    > > >
    > > > > > <form name=form1 method=post action=something.php>
    > > > > > <input type=hidden name=h1 value='' >
    > > > > > <a href="#"
    > > > > > target="childWindowName" onclick="return popup('url.php','Some
    > > > > > name');">Pop</a>
    > > > > > ...
    > > > > > </form>
    > > >
    > > > where does childWindowName reference to? is it necessary for it to be
    > > > there?

    > >
    > > it's not referenced anywhere. correct me if i am wrong (most likely),
    > > target="childWindowName" is the name of the child window and is
    > > required for a popup right? otherwise, i could have use something like
    > > target=_blank
    > >
    > > >
    > > > 'Some name' shouldn't have any spaces in between, so you might want to
    > > > consider 'Some_name'

    > >
    > > actually, it doesn't have space in the actual code. iti's my mistake to
    > > have a space here
    > >
    > > >
    > > > otherwise you could try the onsubmit attribute in form1
    > > >

    > >
    > > i suppose i could do that but i am more interested to find out why my
    > > solution doesn't work in the first place where all online documentation
    > > and code example suggests that it should. i think you are on the right
    > > track that i must have some sort of name-reference thing mess up
    > > between the child and the parent window but the thing is i can get a
    > > reference of the parent window and setting hidden field variables and
    > > such, it's just the submit() method keep saying it's not support
    > >
    > > >
    > > >
    > > > wrote:
    > > > > anyone? any idea?
    > > > >
    > > > > wrote:
    > > > > > hi all,
    > > > > > quick question, how do you submit a form to a parent window from a
    > > > > > child popup window? i have the following and all online documentation
    > > > > > *suggests* that it should work but it does NOT:
    > > > > >
    > > > > > // Parent window:
    > > > > > <script language="JavaScript">
    > > > > > function popup(url, name)
    > > > > > {
    > > > > > window.open(url, name, "width=800,height=600,scrollbars=yes");
    > > > > > return false;
    > > > > > }
    > > > > > </script>
    > > > > > ...
    > > > > > <form name=form1 method=post action=something.php>
    > > > > > <input type=hidden name=h1 value='' >
    > > > > > <a href="#"
    > > > > > target="childWindowName" onclick="return popup('url.php','Some
    > > > > > name');">Pop</a>
    > > > > > ...
    > > > > > </form>
    > > > > >
    > > > > > // Now in the child popup window
    > > > > > <script language="JavaScript">
    > > > > > function handleSubmit(aValue)
    > > > > > {
    > > > > > var myParent = opener.document.forms.form1;
    > > > > > myParent.h1.value=aValue;
    > > > > > myParent.submit(); // ERROR: Object doesn't support this property
    > > > > > or method
    > > > > > return true;
    > > > > > }
    > > > > > </script>
    > > > > > <a href=# onclick="handleSubmit(2006);">Submit</a>
    > > > > >
    > > > > > i have spent a few hours searching online and all the examples
    > > > > > indicates that this example should work but it doesn't, not in IE or
    > > > > > FF. in FF, nothing happen and in IE, the following error show up:
    > > > > >
    > > > > > Object doesn't support this property or method
    > > > > >
    > > > > > any idea? thanks!
    , Jun 13, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Earl Teigrob
    Replies:
    1
    Views:
    5,839
    Earl Teigrob
    Jun 16, 2004
  2. Pat
    Replies:
    1
    Views:
    98
  3. Noel Dolan
    Replies:
    0
    Views:
    227
    Noel Dolan
    Jul 18, 2004
  4. Spammay Blockay
    Replies:
    1
    Views:
    437
    Dietmar Meier
    Feb 4, 2005
  5. Bitswapper
    Replies:
    5
    Views:
    134
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page