I want to
A) open a pop up window via javascript - easy enough
B) close this window via Javascript - easy enough
C) ensure that the window that spawned the popup in A is focused on again when close in B. Seem to remember can do this but can't remember how.
I want to
A) open a pop up window via javascript - easy enough
B) close this window via Javascript - easy enough
C) ensure that the window that spawned the popup in A is focused on again when close in B. Seem to remember can do this but can't remember how.
Share Improve this question edited Sep 1, 2010 at 12:31 Pranay Rana 177k37 gold badges243 silver badges266 bronze badges asked Sep 1, 2010 at 11:11 AJMAJM 32.6k50 gold badges161 silver badges248 bronze badges2 Answers
Reset to default 5script for closing child window and put focus back on parent window
window.opener.focus();
window.close();
Probably the user can close the popup in many ways as with a link, button or close button so a good way is to use the event onunload
so put this in the popup window
window.onunload = function(){
window.opener.focus();
}