嵌套弹出窗口中的javascript window.focus()不起作用

时间:2019-07-24 00:39:27

标签: javascript popup window.open

在Chrome中有三个窗口。 A-是主窗口 B-是'A'的子代 C-是“ B”的子代

在“ A”中,

    var popupB = window.open(...);
    var refC = undefined;

在“ B”中:

    var popupC = window.open(...);
    window.opener.refC = popupC;

和“ A”中的

    popupB.focus() is work
    refC.focus() is doesn't work.

尝试以下:

  

在“ B”中:

   var popupC = window.open(...);
   var fn = function() {
       window.focus();
       popupC.focus();
   }
     

在“ A”中:

   popupB.fn(); // popupB focuss, but popupC was not.

另一个

  

在“ B”中:

   var popupC = window.open(...);
   var fn = function() {
       window.focus();
       setTimeout(function() {
           popupC.focus();
         }, 500);
   }
     

在“ A”中:

   popupB.fn(); // popupB focus, but popupC was not.

如何将嵌套弹出窗口集中在原始父窗口中?

0 个答案:

没有答案