ga**@labdata.com (NeverLift) wrote in message news:<98**************************@posting.google. com>...
But, if it's not open, I don't want to open it . . . using
window.open will open it if it doesn't exist, even if the url in that
open is null (the window is then empty -- but it's open).
This may help...
Is your window that contains the list of open windows a popup? I
assumed that it was, but you could do the same for a frame.
You could track the status of your windows in some variables.
I used the onunload to initiate the tracking of a closed window. I
have heard that onunload was unrelaiable, but it seems tp work for me.
I put an alert at the end of resetVar and observed that resetVar was
invoked and the window closed before I hit enter. This is a good
sign because it shows can get control to do some reseting of control
states, but you are not able to block the window from exiting.
I put together three html files to show how you could track the status
of a popup window. Run main.html. You will see alert messages that
step you through the running.
I tried this on Netscape 7.1 and IE 5.2 under MacOS 10.2.6.
main.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Check before opening:main.html</TITLE>
<SCRIPT type="text/javascript">
function WinObj()
{
this.openned = false;
this.running = false;
this.window = "";
}
var winList = [ ];
winList["winFirst"] = new WinObj();
winList["winSecond"] = new WinObj();
function setVar(name)
{
winList[name].running = true;
}
function resetVar(name)
{
winList[name].openned = false;
winList[name].running = false;
}
function foo(name,htmlFile)
{
var theData, newWindow, URLstring, pass;
theData = "?none=none";
URLstring = htmlFile + theData;
pass = "statusbar,menubar,resizable,toolbar," +
"height=300,width=500,location";
winList[name].window = window.open(URLstring,name,pass);
winList[name].openned = true;
winList[name].window.focus();
}
var maxCheck = 0; // Don't run forever
function checkForOpen()
{
if (winList["winFirst"].running == true)
{
foo("winSecond","winSecond.html");
}
else if (maxCheck++ < 30)
{
setTimeout("checkForOpen()",1000);
}
else
{
alert("setTmeout for checkForOpen has ended");
}
}
</script>
</HEAD>
<BODY onload='
alert("Try to open a new window next.");
foo("winFirst","winFirst.html");
setTimeout("checkForOpen()",1000);'>
<p>Lets open two windows.</p>
</BODY>
</HTML>
winFirst.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Little html window: winFirst.html</TITLE>
</HEAD>
<BODY
onload='alert("Onload in winFirst.html, " +
"press enter within thirty seconds to open " +
"winSecond.html.");
opener.setVar("winFirst");'
onunload='opener.resetVar("winFirst");'>
<p>I am a very small html file,
but I hope to grow up someday.</p>
</HTML>
winSecond.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<SCRIPT type="text/javascript">
function startUp()
{
alert("From winSecond.html, " +
"focus should now go to winFirst.html " +
"after calling setVar. " +
"( Should you close the winFirst.html window. " +
"You will get another alert. " +
"To see both paths, you may press enter, " +
"then close winFirst.html then reload this one. )");
opener.setVar("winSecond");
if (opener.winList["winFirst"].openned == true)
{
opener.winList["winFirst"].window.focus();
}
else
{
alert("Problems today. Where is winFirst.html?");
}
}
</script>
<HEAD>
<TITLE>Little window too: winSecond.html</TITLE>
</HEAD>
<BODY onload='startUp();'
onunload='opener.resetVar("winSecond");'>
<p>I am too a small html file,
but I hope to grow bigger someday too.</p>
<p>Most programs seem to go that way, amigo.
Not me. I grow in complexity, but stayed small.</p>
</HTML>
Robert