0

My parent window calls a child window and moves focus to it. This works fine. On the child window I want to set focus back to parent window from child window. This works only if I use alert/confirm on parent window. But I don't want my users to click away alert popups all the time. Is there an opportunity to move focus back?

Parent-Window calls child:

function OpenWindow() {
    child = window.open("ZLab/Child", '_blank');
}

Parent-Window sends message and sets focus on child:

function SendMessage() {
    child.postMessage({ param: new Date() }, "/");
    child.focus();
}

Child-Window calls Parent-Window

function OpenParent() {
    opener.GetBack();
}

Parent-Window gets control back. window.focus() doesn't get really focus, just alert/confirm works.

function GetBack() {
    alert("Hi, back again");
    //window.focus();
}
  • So do you want it to refocus on the child or the parent.. do you have a link to the site – Trevor Clarke Mar 26 '16 at 17:20
  • I don't think this is possible...see http://stackoverflow.com/questions/18501095/window-opener-focus-doesnt-work. Consider using a JavaScript modal window instead. The contents of the modal could be an iframe, if that makes it easier for you. – Matt Browne Mar 26 '16 at 17:21
  • I want to refocus it on the parent. The example is not online. – Reto Bergamin Mar 27 '16 at 14:55
  • Can't really use modal popup or iframe. The real app's parent as well as child windows are huge pages. So keep with alert/confirm is better then. Thanks for help. – Reto Bergamin Mar 27 '16 at 15:17

0 Answers0