post form to window opener

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • humbads

    #1

    post form to window opener

    I am trying to get a popup window to work for editing notes in my
    application. Here's how I implemented it:

    The original frame is called ORIGINALFRAME and contains a link like
    this:

    <a href="javascrip t:launchwin();" >Edit Note</a>
    function launchwin() {
    // ... custom stuff
    newNoteWindow = window.open(str URL,'NoteWindow ',strOptions);
    if(newNoteWindo w.opener == null) {
    newNoteWindow.o pener = self;
    }
    if (window.focus) {
    newNoteWindow.f ocus();
    }
    }

    In the resulting pop-up window, I have a POST form whose onSubmit
    handler contains these lines:

    document.forms[0].target=window. opener.name; // becomes ORIGINALFRAME
    document.forms[0].submit();
    window.close();

    I am passing the URL of the ORIGINALFRAME as a query string parameter
    to the pop-up window. In the page that handles the form submission, it
    reads this parameter and redirects to it after processing the form.
    This way, the original frame appears to reload, and it only reloads
    after the form is completely processed.

    The implementation doesn't work in either IE or Firefox when there is
    more than one original frame with the same name in multiple windows.
    In Firefox, the post is directed to the first original frame, while in
    IE, it doesn't seem to do anything.

    The POST form is in the pop-up window. Does anyone know how to set its
    target to the opener, reliably?

  • humbads

    #2
    Re: post form to window opener

    To solve this, instead of changing the target of the form to the
    opener, I could instead post directly to the self window (the pop-up
    window). Then I use some javascript in the form response to refresh
    the opener and close the window, like this:

    ' Form Handler (In ASP) - Show a javascript page to
    ' refresh the opener and close the pop-up window
    %><html><head>
    <script type="text/javascript">
    function CloseWindow() {
    window.opener.l ocation.href='< %=RedirectURL%> ';
    window.close();
    }
    </script>
    </head><body
    onload="CloseWi ndow();"></body></html><%
    Response.End

    But this is not the most elegant solution...

    Comment

    Working...