Jump to content

window.close cancels previous actions?


chadmichael

Recommended Posts

what I'm doing I have a secondary window ( a window that I've opened from the main browser ). There's a form in it. When I submit the form, I want the window to close and the return from the response to go to the main browser window that opened the secondary window. I've got this work, minus the closing of the secondary window, by using the following function that is called to submit the form.

function submitForm(){	   /* set the target of the form to the name of the opening window */       document.DMUForm.target = opener.name;   document.DMUForm.submit();}

This works great. But when I try to add a line to close the secondary window (code below), the first two lines fail. I guess its something like that the secondary window is closed before it has a chance to submit the request?

function submitForm(){	   /* set the target of the form to the name of the opening window */       document.DMUForm.target = opener.name;   document.DMUForm.submit();   /*  close me ( I'm the secondary window ) */   window.close();}

Link to comment
Share on other sites

Well, what you can do is put this in the pop up window:

<script language="javascript" type="text/javascript">var oParent = window.opener;document.DMUForm.target=oParent.namewindow.close();</script>

Is this what you want?

Link to comment
Share on other sites

Hmm...I really don't know. Oh, you have to remove the () after window.close, as you're not supposed to use () when calling a javascript function IN javascript. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...