Wednesday, September 30, 2009

JavaScript : Close pop-up window and redirect to parent page

:target => adds the html attribute target to the link. This opens up a new window and names the new window the target.

You have to use javascript or Ajax to redirect the old page,

window.opener.location.href="http://new_url";

and then close the old window.

window.close();

This can be done either through the rjs file or directly in the javascript.

2 comments: