Dear Dr. Website®: I am a novice Web developer. I know Perl is the scripting language used in writing CGI, and that all CGI files must have .cgi extensions. But why do some books I've read have CGI programs ending in .pl?
Second, for .pl programs, you need to compile, and this does not go through the server, right? But CGI (Perl) programs do, correct?
You have come close to answering your own question!
CGI stands for Common Gateway Interface, and it's simply a way to allow programs running on a server to interact with a user working on a browser. CGI programs can be written in virtually any programming language.
Perl is frequently used not because it's mandatory, but because it's a good all-around language for this kind of work, and, being freely available, it will run on almost any server.
The file extension for Perl is .pl, so if a CGI program is written in Perl, either that or .cgi will work.
However, do note that Perl is actually not generally compiled at all, but interpreted, which means changes that happen to Perl programs immediately take effect. There are Perl compilers available, however.
Please visit the CGI pages at http://webdeveloper.com/categories/cgi-perl/index.html and http://wdvl.com/Authoring/CGI/ for more information on CGI programming, as well as our own FAQ page.
Dear Dr. Website®: How can I implement a counter into a Web page without using one of those so-called free ones, and where do I store the code within the Web site folder?
You can download a counter script from many sites,
such as our own ScriptSearch.com.
You will have to configure the script for your particular Web server, and you will need CGI-BIN access. The script will be run from within your site's CGI-BIN directory.
Do keep in mind that in general, counters are, well, counter-productive. Nobody really cares how many hits your site gets; just look at any of the top sites on the Web -- none of them use counters. Counters are a reminder of what the Web was made up of five years ago.
Dear Dr. Website®: How do you make a new automatically launched window that goes to a URL if the user exits from our site?
Although I would encourage you to use this script sparingly
-- as it can be an annoyance for your visitors -- you can achieve this effect by using the onUnload event:
<SCRIPT LANGUAGE="JavaScript">
<!--//
function openit(sURL){
newwindow=open(sURL,"newwin","width=300,height=300");
}
//-->
</SCRIPT>
</head>
<body onUnload="javascript:openit
('smallwin.html')" >
this is some random text
</BODY>
By using the onUnload event, you substitute the name of the page you wish to appear in the openit function instead of "smallwin.html."
You can also change the height and width settings, or add or remove other window settings, such as whether scrollbars, toolbars, etc. appear on the window by adding their parameters to the open function, i.e.:
<SCRIPT LANGUAGE="JavaScript">
<!--//
function openit(sURL){
newwindow=open(sURL,"newwin","scrollbars=no,toolbar=no,
directories=no,menubar=no,
resizable=no,status=no, width=300,height=300");
}
//-->
</SCRIPT>
</head>
<body onUnload="javascript:openit
('smallwin.html')">
this is some random text
</BODY>