最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Javascript - focus on calling window after a close - Stack Overflow

programmeradmin3浏览0评论

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(); 
}
发布评论

评论列表(0)

  1. 暂无评论