AJM
AJM

Reputation: 32500

Javascript - focus on calling window after a close

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.

Upvotes: 2

Views: 3776

Answers (2)

Luka Milani
Luka Milani

Reputation: 1541

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

Upvotes: 1

Pranay Rana
Pranay Rana

Reputation: 176956

script for closing child window and put focus back on parent window

window.opener.focus(); 
window.close();

Upvotes: 5

Related Questions