views:

1715

answers:

3

Hello,

I am using the popupwindow plugin for jquery to show a form in a popupwindow. How can I close this window after submitting? This is the link I am talking about. I can open a link in a pupup window. But after submitting I want it to open in its parent window.

+1  A: 

Use Ibox or DHTML Window

Click Upvote
why this one? Is the one I use not good?
sanders
A: 

Perhaps you should use this property:

window.opener

The opener property corresponds to the window that opens the window. When accessed by a child window, it returns the parent window.

Koistya Navin
+10  A: 

In your popup-ed page, you can re-format the said link to match the following code:

<a href="javascript: self.opener.location = 'http://somewhere.ltd/path/to/dir'; self.close();">
     Let's go Somewhere
</a>

Additionally I recommend you to use Javascript in an unobtrusive way instead of using the simple line above.
Ok, and about that "Fade" operation! you can't do such a thing to operating system (no matter what) window using Javascript.

update: Assuming the form with id property "theChildForm" & using jQuery:

$("#theChildForm").submit(function(){
     //TODO: some data keeping jobs to be done
     self.opener.location = 'http://somewhere.ltd/path/to/dir'; //pass the url if needed
     self.close();
     ...
    });
Sepehr Lajevardi
How would i do this if i use a submit input type in a form?
sanders
use the code as the form's submit handler (onsubmit). feel free to tell, if you need an updated answer. http://is.gd/qPg5
Sepehr Lajevardi
but that's no jquery, is there a way to do it in jquery?
sanders
Sepehr Lajevardi
so how would my submit button and the jquery code look like in unubstructive js?
sanders
like the updated code above.
Sepehr Lajevardi