3

I've written a web page that kind of behaves as a sort of kiosk: when it opens, it detects if it's the controlling window. If not, it loads the controlling window page, and opens the index page again in a new window so it can detect the opener pointers. The second window then contains a link which opens an arbitrary url in a third window. My controller window detects whether this second window is open, and if any other window is focused, it brings that window back to the front.

This arbitrary website at some point in the process opens another window for a quiz (not controlled by my site), but this new window keeps getting pushed to the back because my code keeps bringing my second window forward. Is there any way I can detect whether the second window has opened another window, and if so, prevent my window from getting focus?

The code below runs 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, which is running on 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's 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 much appreciated.

In the first else if, where I call accelWindow.focus(), is where I would like to check if accelWindow has any children windows (which means they opened the quiz), and if so, not call accelWindow.focus().

PS This is my first post/question :)

1 Answers1

0

You could show those "windows" contents in some sort of frame inside the same browser window, inside the same app.. you could use a ligthbox. Using a browser based app that works with more than more window seems to be uncomfortable.

rccursach
  • 305
  • 3
  • 14