Article
Dr. Design - Popups, Domain Names, Copyright and More
The Doctor is in! This week he has a long line of patients waiting -- and if you'd like to join the queue, email him your questions at drdesign@sitepoint.com
Resizing An Already Open Popup Window
Hey Doc,
I need to know how to close a Popup window from a parent window.
I have a parent page with 4 swf buttons. Each button activates a popup window _blank, and each window _blank is a different size.
Now, here’s the problem. The first button that is selected on the parent page spawns a window – but then the size of that window is applied to all windows that are spawned from that point on.
I want each window to popup to the specific size that I’ve assigned it, so I’d like the current window to close every time the user clicked a button. This will allow the window to resize based upon the button’s popup window specs, rather than the specs of an already-open window.
Have I confused you? I've been using javascripts to amend this problem, but I can't make it work:
on (press) {
getURL (javascript:closepopup(), _blank);
}
on (release) {
getURL
("javascript:openNewWindow('http://www.name,html','thewin',
'height=370,width=300,toolbar=no,scrollbars=no')",
_blank);
}
Help! Afiyf
Afiyf, although I am a doctor (in case you didn’t know already), yes I am easily confused. However, I have just the right javascript potion for the symptoms you describe.
To close a popup window from the parent window, we just need to call it using its object handle. For example, if we opened the window like this:
myWindow = open('http://www.name,html','thewin',
'height=370,width=300,toolbar=no,scrollbars=no');
We can close that window from the parent:
myWindow.close();
However there might be a simpler fix to your problem that doesn't involve closing the open window and then opening it again. You can simply resize the window.
Here’s an example:
<script language="javascript">
function popWindow(url, width, height) {
popUp = open(url, 'thewin', 'toolbar=1,
scrollbars=1, location=1, status=1, menubar=1, resizable=1');
popUp.resizeTo(width, height);
}
</script>
<a href="javascript:popWindow('http://www.webmasterbase.com',10, 10)">
popup small</a><br>
<a href="javascript:popWindow('http://www.promotionbase.com',600, 600)">
popup large</a>
Note, though, that resizeTo may not be supported in pre-version 4 browsers. Have fun!
Using SSI Inside a CGI Perl Script
Hi Dr. Design,
I've successfully used SSIs to bring in standard header and footer code in .shtml files. It would be nice to use the same headers and footers on CGI output. For example, I have a Perl script that processes a form and displays one of several pages in response. Ideally, I could just put an SSI include tag in the html code created by the script. Unfortunately, my hosting server doesn't process these tags. Is there a way to make this work? Thanks!
Emmanuel
Emmanual, there are two approaches you could take:
1) Instead of calling your SSI from your CGI script, which as you have already mentioned doesn't work, you can call your CGI script from your SSI. So your shtml page might look something like:
<!--#include virtual="/templates/top.html" -->
<!--#exec cgi="/cgi-bin/script.cgi"-->
<!--#include virtual="/templates/bottom.html" -->
2) If you want to simulate an SSI include file in your Perl script, you simply need to add a few lines to the script that will open your include file, read it and print it out (to the browser).
Here is some Perl script that opens a file and reads its contents into an array, before printing out each line.
open(FILE,"templates/top.html") or dienice("Can't open
include.html: $!");
@ary = <FILE>;
close(FILE);
foreach $line (@ary) {
chomp($line);
print "$line\n";
}
Dr Design answers design and development questions for SitePoint readers.