Question

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.

Was it helpful?

Solution

You can attach the behavior to your link, in the popup-ed page:

<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.

About that "Fade" operation; You can't do such a thing to the OS window using Javascript (no matter what).

Update: Assuming the form with id property theChildForm and using jQuery:

$("#theChildForm").submit(function() {
     // TODO: Some data keeping jobs to be done
     // Pass the url if needed
     self.opener.location = 'http://somewhere.ltd/path/to/dir';
     self.close();
     // ...
    });

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top