Can javascript detect if another window has opened in a window?

I wrote a web page that behaves like a kiosk of sorts: when it opens, it detects if it is a control window. If not, it loads the control window page and reopens the index page in a new window so that it can detect the opener pointers. The second window then contains a link that opens an arbitrary URL in the third window. My controller window determines if this second window is open, and if any other window is focused, it brings that window back.

This arbitrary website at some point in the process opens up another window for the quiz (not monitored by my site), but this new window keeps pushing backwards because my code keeps pushing my second window forward. Is there any way to detect if the second window has opened another window, and if so, my focus cannot be opened?

Below is the code below on the main page (index.php)

var bypass = <?=($b==1?'true':'false')?>;
if(!bypass && !window.opener && navigator.appVersion.indexOf('Mac') != -1){
    window.location = '/labs/rearWindow.php';
}

      

Below is my code that runs in the controller window (rearWindow.php)

var mainWindow = null;
var accelWindow = null;
var windowSettings = 'channelmode=yes,fullscreen=yes,height='+screen.availHeight+',width='+screen.availWidth+',left=0,top=0';

$(document).ready(function(){
    window.moveTo(0,0);
    window.resizeTo(10, 10);
    checkWindow();
});

function checkWindow(){
  if(mainWindow == null || mainWindow.closed){
    // If the main window doesn't exist or it been closed, open new window to the index
    mainWindow = window.open('/labs/index.php', 'mainLabWindow', windowSettings);
    if(!mainWindow){
      // If the window didn't open in the satement above (usually because pop-ups are blocked), open up current window to an alternate url
      window.location = '/labs/index.php?b=1';
    }
  }else if(mainWindow != null && !mainWindow.closed && accelWindow != null && !accelWindow.closed){
    // If main window is already open and it hasn't been closed and the AR window has been opened and hasn't been closed
    accelWindow.focus();
  }else if(mainWindow != null && !mainWindow.closed && accelWindow != null && accelWindow.closed){
    // If main window has been opened and hasn't been closed and AR window has been opened but has been closed; then go back to main window
    accelWindow = null;
    mainWindow.focus();
  }else if(mainWindow != null && !mainWindow.closed){
    // If main window has been opened and has not been closed
    mainWindow.focus();
  }
  setTimeout(checkWindow, 500);
}

      

Your help and feedback is greatly appreciated.

In the first if case, where I call the accelWindow.focus () method, I would like to check if the windows acceleration window has any child windows (which means they opened a quiz), and if so, do not call accelWindow. focus ().

PS This is my first post / question :)

+3


source to share


1 answer


You can show these "windows" content in some frame inside the same browser window, inside the same application .. you can use ligthbox. Using a browser with more than one window seems awkward.



0


source







All Articles