admin管理员组

文章数量:1432588

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 badges
Add a ment  | 

2 Answers 2

Reset to default 5

script 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(); 
}

本文标签: Javascriptfocus on calling window after a closeStack Overflow