Click to See Complete Forum and Search --> : Override a pop-up window with a new one


haynbrian
02-19-2003, 08:44 AM
I am wondering if you are able to over-ride a pop-up window with another pop-up window's dimensions. I am creating a website with information via a onClick event to trigger another .html file that appears as a small pop-up to keep the site relatively clutter free. What I want to do is if the user clicks on an information link and forgets to close the first window, to be able to have the second window over-ride the first windows dimentions and placement. I have some example code below. I have take away style to keep the code relatavely simple to read. Any help is greatly appreciated.

<html>
<head>

<script language="JavaScript">
var UtilWindow
function makeUtility() {
UtilWindow = window.open("samplefile.htm", "def", "height=300,width=300")
}
</script>
<script language="JavaScript">
var FrameWindow
function makeFrame() {
FlexWindow = window.open("samplefileTwo.htm", "def", "height=300,width=400")
}

</script>


</head>

<body>

<span onclick='makeSite()' litup1>link to pop-up</span>
<span onclick='makeFrame()' litup1>link to over-ride</span>

</body>

</html>

AdamBrill
02-19-2003, 12:44 PM
How about something like this:
<html>
<head>

<script language="JavaScript">
var UtilWindow =null;
function makeUtility() {
UtilWindow = window.open("samplefile.htm", "def", "height=300,width=300")
}
</script>
<script language="JavaScript">
var UtilWindow;
function makeFrame() {
if(UtilWindow)
{
UtilWindow.close();
}
UtilWindow = window.open("samplefileTwo.htm", "def", "height=300,width=400")
}

</script>


</head>

<body>

<span onclick='makeUtility()' litup1>link to pop-up</span>
<span onclick='makeFrame()' litup1>link to over-ride</span>

</body>

</html>
Let me know if that will work for you...

haynbrian
02-19-2003, 11:28 PM
Adam,

Thanks for your reply. That is a good solution. However, I have about 6 different links to new windows, all of which are of different dimensions (I would make them all the same dimension but some are pictures and some are text, and I'm real picky about border size etc.). So what happens is that it will close the one that I tell it to, but that is only if they click on that one, not one of the 5 others.

I'm probably missing something seriously easy. Any other ideas?

Thanks,

Brian

AdamBrill
02-19-2003, 11:34 PM
How about naming all of the windows the same thing? ;) Just have all of them do it like this:

UtilWindow = window.open("samplefile.htm", "def", "height=300,width=300");

Then the next one like this:

UtilWindow = window.open("samplefile2.htm", "def", "height=300,width=400");

Use UtilWindow for all of the windows that you open and remember to use my code to close the window before it opens it again...

haynbrian
02-19-2003, 11:44 PM
Hmm. I never thought of that. So my next question is this, how would it pull up the correct page if they are all the same function name? Would I have to name the span tag that I am using and make a reference to that in the script? Or would it go down through every page in succession, which might work well if it was a sequenced set of links, but that isn't the case here.

Thanks again,

Brian

AdamBrill
02-19-2003, 11:50 PM
No, just do it like this:
<script language=javascript>
UtilWindow=null;
function link1()
{

if(UtilWindow)
{
UtilWindow.close();
}
UtilWindow = window.open("samplefile.htm", "def", "height=300,width=300")
}


function link2()
{
if(UtilWindow)
{
UtilWindow.close();
}
UtilWindow = window.open("samplefileTwo.htm", "def", "height=300,width=400")
}


</script>
Hope that clears it up... :)

haynbrian
02-19-2003, 11:52 PM
Okay, gotcha. I'll give it a try

Brian

haynbrian
02-24-2003, 09:08 PM
Finally got around to trying the code you recommended. Worked great. Thanks.