View Full Version : Parent Child windows
jecker
Jun 19th 2007, 5:02 pm
I am trying to create a parent child window relationship were the parent window cannot be made active until the child window is closed. Is that possible, if so how can I make this happen?
newbish
Jun 19th 2007, 6:38 pm
I have not tested this but and haven't done JS in a while but, you could have the parent window set the focus to the child and set a variable. Then have the parent check the variable on focus, if the value is set re-focus the child. To unset the value of the parent window when the child is completed use the "opener" syntax to refer to the parent.
Parent
var focusChild = false;
var theWin;
function OpenWindow() {
theWin = window.open(...);
focusChild = true;
...
}
function CheckVar() {
if (focusChild)
theWin.focus();
}
function FocusParent() {
focusChild = false;
}
window.onfocus = CheckVar;
Child
function UnsetFocus() {
opener.FocusParent();
}
window.onunload = UnsetFocus;
krt
Jun 19th 2007, 6:42 pm
A web app is not as capable as a desktop app and making one act like that often causes problems with usability. If you must, then how about explaining why you want to do this, there are a few things I am thinking of but I doubt they would be suitable - e.g. covering the parent page rendering it useless, using a layer on top of the page instead of a child window... I doubt you can take restrict focus to the parent, at least in a cross browser compatible manner.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.