post form to window opener

H

humbads

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="javascript:launchwin();">Edit Note</a>
function launchwin() {
// ... custom stuff
newNoteWindow = window.open(strURL,'NoteWindow',strOptions);
if(newNoteWindow.opener == null) {
newNoteWindow.opener = self;
}
if (window.focus) {
newNoteWindow.focus();
}
}

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?
 
H

humbads

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.location.href='<%=RedirectURL%>';
window.close();
}
</script>
</head><body
onload="CloseWindow();"></body></html><%
Response.End

But this is not the most elegant solution...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,779
Messages
2,569,606
Members
45,239
Latest member
Alex Young

Latest Threads

Top