Problem with window.opener in Firefox/Mozilla

Discussion in 'Javascript' started by fogwolf, Aug 31, 2004.

  1. fogwolf

    fogwolf Guest

    First a basic outline of what I am trying to do:

    I want to have a page spawn a pop-up when you click "submit" on its
    form. On this pop-up page there will be another form. When you click
    "submit" on the pop-up's form I want the pop-up to close & a new page
    to load in the "parent" window/page. I have this working in IE but
    cannot get it to work in Firefox. The parent window correctly loads
    the new page after submitting from the pop-up, however the pop-up will
    not close. Here is what I have in my pop-up page:

    <body bgcolor=#fffff0
    onLoad="window.opener.name='mainPage';window.opener.opener=window">

    Basically giving a name to the parent window & then setting the parent
    window's opener to the pop-up. Here is my form tag for the pop-up
    page:

    <form action=geturls.jsp target="mainPage" onSubmit="return
    validate(this)">

    So now the target of the submission from the pop-up is the initial
    parent window. The next page which loads in the parent window (after
    submitting from the pop-up) has the following body tag:

    <body bgcolor=#fffff0 onLoad="javascript:window.opener.close()">

    Since I set the pop-up as the opener of the parent window from the
    pop-up html with the tag I show above, this should work. It does work
    perfectly in IE but in Firefox the pop-up stays open & I get the
    following javascript error:

    window.opener has no properties

    I am using Firefox 0.9.3.

    I should also mention that the "validate()" method in pop-up needs to
    return "true" if there are no validation errors with the pop-up's form
    & then post the form to the main page since it loads a *different*
    page (i.e. it doesn't just reload the page already loaded in the
    parent window), so I cannot just call "window.close()" in the
    validate() function.

    Thanks!
     
    fogwolf, Aug 31, 2004
    #1
    1. Advertisements

  2. fogwolf

    Grant Wagner Guest

    fogwolf wrote:

    > First a basic outline of what I am trying to do:
    >
    > I want to have a page spawn a pop-up when you click "submit" on its
    > form. On this pop-up page there will be another form. When you click
    > "submit" on the pop-up's form I want the pop-up to close & a new page
    > to load in the "parent" window/page. I have this working in IE but
    > cannot get it to work in Firefox. The parent window correctly loads
    > the new page after submitting from the pop-up, however the pop-up will
    > not close. Here is what I have in my pop-up page:
    >
    > <body bgcolor=#fffff0
    > onLoad="window.opener.name='mainPage';window.opener.opener=window">
    >
    > Basically giving a name to the parent window & then setting the parent
    > window's opener to the pop-up. Here is my form tag for the pop-up
    > page:
    >
    > <form action=geturls.jsp target="mainPage" onSubmit="return
    > validate(this)">
    >
    > So now the target of the submission from the pop-up is the initial
    > parent window. The next page which loads in the parent window (after
    > submitting from the pop-up) has the following body tag:
    >
    > <body bgcolor=#fffff0 onLoad="javascript:window.opener.close()">
    >
    > Since I set the pop-up as the opener of the parent window from the
    > pop-up html with the tag I show above, this should work. It does work
    > perfectly in IE but in Firefox the pop-up stays open & I get the
    > following javascript error:
    >
    > window.opener has no properties
    >
    > I am using Firefox 0.9.3.


    It would appear that Firefox does not set window.opener when a window is
    opened using the TARGET attribute alone. So open the window using
    JavaScript and window.opener will be set appropriately (assuming the
    window opens at all that is).

    Variation on <url: http://jibbering.com/faq/#FAQ4_37 />:

    <form action=geturls.jsp target="mainPage"
    onSubmit="
    if (validate(this)) {
    window.open('', this.target);
    return true;
    } else {
    return false;
    }
    "
    >


    --
    Grant Wagner <>
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Grant Wagner, Aug 31, 2004
    #2
    1. Advertisements

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. Andrew Bewley via DotNetMonster.com

    window to window communication (window.opener)

    Andrew Bewley via DotNetMonster.com, Feb 3, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,160
    Andrew Bewley via DotNetMonster.com
    Feb 3, 2005
  2. Urs Gubler
    Replies:
    0
    Views:
    219
    Urs Gubler
    Jul 2, 2003
  3. Yaron C.

    opener.opener ?

    Yaron C., Oct 30, 2003, in forum: Javascript
    Replies:
    4
    Views:
    280
    Yaron C.
    Nov 2, 2003
  4. atlas
    Replies:
    1
    Views:
    172
    Martin Honnen
    Sep 7, 2005
  5. window.opener, form.opener?

    , Jul 14, 2006, in forum: Javascript
    Replies:
    5
    Views:
    360
Loading...

Share This Page