chadmichael Posted January 17, 2006 Share Posted January 17, 2006 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 More sharing options...
Chocolate570 Posted January 17, 2006 Share Posted January 17, 2006 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 More sharing options...
chadmichael Posted January 17, 2006 Author Share Posted January 17, 2006 No, I don't think so. As I said, the part about setting the target and submitting the form works. Its just that when I add the window.close() it seems to interfere with the execution of the previous lines. Link to comment Share on other sites More sharing options...
Chocolate570 Posted January 18, 2006 Share Posted January 18, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now