Forum Moderators: open
c=0;
while (c < howMany)
{
alert("while Loop: "+c);
if (subWins[c] &&!subWins[c].close())
{
alert("If 1: "+c+", "+subWins[c].name+", "+winName);
if ((subWins[c].name.toLowerCase()) == winName.toLowerCase())
{
alert("If 2: "+c);
subWins[c].close();
winOpen(opts, winType, c);
alreadyOpen = true;
break;
}
}
c++;
}
Firefox alerts are...
While Loop: 0;
If 1: 0, win2, win2
then it fails and says "Window.name has no properties"
IE looses it right after "While Loop: 0" and says access denied.
Any ideas? I've been looking around for a while. It's just odd that firefox would let me access the data and then say no way.
Thanks...
-Jay
the subWins array actually does this, it's a global, and instead of using a return value, I just assign it in the winOpen method.
Here's the code in it's completeness, (it's in a linked js file.)
var subWins = new Array();
var opts = new Array();
var howMany = 0;
var popWidth = 0;
var popHeight = 0;function winPopUp(URL, popWidth, popHeight, winName, winType)
{
alert("Creating Window: "+winName);
var ScreenWidth = window.screen.width;
var ScreenHeight = window.screen.height;opts[0] = URL;
opts[1] = winName;if (ScreenHeight < 650 && popHeight > 450)
{
popHeight = 425;
}
opts[2] = popWidth;
opts[3] = popHeight;var placementx = (ScreenWidth/2)-((popWidth)/2);
var placementy = (ScreenHeight - popHeight)/2 - (ScreenHeight - popHeight)/4;opts[4] = placementx;
opts[5] = placementy;windowManager(winName, opts, winType);
}function windowManager(winName, opts, winType)
{
var c = 0;
var alreadyOpen = false;
while (c < howMany)
{
alert("while Loop: "+c);
if (subWins[c] &&!subWins[c].close())
{
alert("If 1: "+c+", "+subWins[c].name+", "+winName);
if ((subWins[c].name.toLowerCase()) == winName.toLowerCase())
{
alert("If 2: "+c);
subWins[c].close();
winOpen(opts, winType, c);
alreadyOpen = true;
break;
}
}
c++;
}
if (howMany == 0)
{
winOpen(opts, winType, 0);
howMany++;
alreadyOpen = true;
}
if (!alreadyOpen)
{
winOpen(opts, winType, howMany)
howMany++;
}}
function winOpen(opts, winType, c)
{
//alert("in winOpen. Opening window: "+opts[1]);
if (winType == 1)
{
alert(opts[1]);
subWins[c] = window.open(opts[0],opts[1], "width="+opts[2]+",height="+opts[3]+",toolbar=0,location=0,directories=0,status=0,scrollbars=0,
menubar=1,resizable=1,left="+opts[4]+",top="+opts[5]+",screenX="+opts[4]+",screenY="+opts[5]+",");
}
else
{
subWins[c] = window.open(opts[0],opts[1], "width="+opts[2]+",height="+opts[3]+",toolbar=1,location=0,directories=0,status=1,scrollbars=1,
menubar=1,resizable=1,left="+opts[4]+",top="+opts[5]+",screenX="+opts[4]+",screenY="+opts[5]+",");
}
alert("Window '"+subWins[c].name+"' created at subWin["+c+"]");
subWins[c].focus();}
<html>
...
<a href="somPage.html" target="win2" onClick="winPopUp('somePage.html','660','600','win2', 0);">page1</a>
<br>
<a href="someOtherPage.html" target="win2" onClick="winPopUp('someOtherPage.html','660','600', 'win2', 0);">page2</a>
...
</html>
Based on the browsers' behavior, something's happening to my subWins array and I Can't figure it out. Any idea's? It'd be a nice little window manager if I could get it working and didn't run into any cross browser problems.
-Jay_r