View Full Version : Reusable, resizable popup windows needed
Evil Dust Bunny
11-16-2004, 04:34 PM
On this page ('http://foundry.mc.maricopa.edu/~donut/projects/CommLogs/logs.html') I have a bunch of links that create popup-windows. The problem is that not every window is the same size, but I want each link to open in a single popup (ie, reuses the window). This is working right now, but the window does not resize and is not brought to the front.
pesty
11-18-2004, 02:32 AM
To my knowledge there isn't anyway to reuse or automatically resize one pop-up window for varies links.
If someone knows of a way, let us both know.
coothead
11-18-2004, 02:44 PM
Hi there Evil Dust Bunny,
try this....
<base href="http://foundry.mc.maricopa.edu/~donut/projects/CommLogs/"> /*used for my testing purposes only*/
<script type="text/javascript">
<!--
var mypopup;
function createPopup(url,w,h,num) {
var l=(screen.width-w)/2;
var t=(screen.height-h)/2;
var features="width="+w+",height="+h+",left="+l+",top="+t+",toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0";
if(navigator.appName=="Opera") {
mypopup=window.open(url,"popup"+[num],features);
mypopup.focus();
}
else {
if(mypopup) {
mypopup.close();
}
mypopup=window.open(url,"popup",features);
mypopup.focus();
}
}
// -->
</script>
<table width="100%" border="0" bordercolor>
<tr align="center" valign="top">
<td width="33%" class='tdBorder'>
<div align="center" class="subheadb">TGIF Logs
<p class="subheadc">
<a href="javascript:void(createPopup('2004-02-20.htm',300,355,0))">February 20, 2004</a>
</p>
<p class="subheadc">
<a href="javascript:void(createPopup('2004-02-27.htm',400,370,1))">February 27, 2004</a>
</p>
<p class="subheadc">
<a href="javascript:void(createPopup('2004-03-05.htm',500,350,2))">March 5, 2004</a>
</p>
</div>
</td>
<td width="33%" class='tdBorder'>
<div align="center" class="subheadb">FAQ Logs
<p class="subheadc">
<a href="javascript:void(createPopup('2004-02-20.htm',300,355,3))">February 20, 2004</a>
</p>
</div></td>
</tr>
</table>
...as you can see I have modified four of the links,
I will leave the rest to you :D
Evil Dust Bunny
11-18-2004, 02:44 PM
Well, I haven't exactly found a perfect solution, but one that works well enough. Basically, close the popup before opening the new one. Not as purdy, but it works.
Here's the code I'm using:var
<script type='text/javascript'><!--
popupWin = "";
function createPopup(url, w, h){
if (popupWin != "") { popupWin.close(); }
popupWin = window.open(url, "popup", "toolbar=0,location=0,directories=0,status=0,
scrollbars=0,resizable=0,width="+w+",height="+h);
return false;
}
// --></script>
And in the body:<a href='2004-02-20.htm' onClick="return createPopup(this.href,300,355);">February 20, 2004</a>
Hope that helps. Oh, right, I got this solution from from Warren86's post here ('http://www.webdeveloper.com/forum/showthread.php?s=&threadid=49202') at Web Developer Forums (http://www.webdeveloper.com). Sorry if posting this link is illegal. I'll take it down if tell me to. I just would like to give credit where credit is due.
Edit: From what I can tell, coothead's solution does the same thing mine does but adds extra support for Opera? Oh, and centers the popup which is something I don't want. Am I missing something?
coothead
11-18-2004, 06:40 PM
Hi there Evil Dust Bunny,
the code that you are using on your link does not appear
to work with Opera 7.54...probably needs my workaround :D
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.