PDA

View Full Version : Question about CGI


wind0965
01-20-2004, 04:27 PM
The code is:

<script language=javascript type="text/javascript">
<!--
var countimg = 0;
function reloadImage()
{
var da = new Date();
if (document.imglive)
document.imglive.src = "/rec/img.cgi?" + countimg + "+out.jpg";
countimg ++;
delete da;
}
function reloadAfter()
{
window.setTimeout("reloadImage()", 1900);
}

function reloadCounter()
{
var da = new Date();
if (document.imgcounter)
document.imgcounter.src = "/rec/imgcnt_xxxxxxxx.cgi?" + countimg + "+out.bmp";
countimg ++;
delete da;
}
function reloadCounterAfter()
{
window.setTimeout("reloadCounter()", 1600);
}

function isLoaded() {
reloadImage();
reloadCounter();
}
// -->
</script>


What does "/rec/img.cgi?" + countimg + "+out.jpg" mean?
1. Why there is a "?" after .cgi?
2. What does the "+" mean?
3. Are the counting and "+out.jpg" parameters or something else?

I am not familiar with CGI, hope you may help me.
Thank you in advance!

YUPAPA
01-21-2004, 02:37 AM
Originally posted by wind0965
The code is:

<script language=javascript type="text/javascript">
<!--
var countimg = 0;
function reloadImage()
{
var da = new Date();
if (document.imglive)
document.imglive.src = "/rec/img.cgi?" + countimg + "+out.jpg";
countimg ++;
delete da;
}
function reloadAfter()
{
window.setTimeout("reloadImage()", 1900);
}

function reloadCounter()
{
var da = new Date();
if (document.imgcounter)
document.imgcounter.src = "/rec/imgcnt_xxxxxxxx.cgi?" + countimg + "+out.bmp";
countimg ++;
delete da;
}
function reloadCounterAfter()
{
window.setTimeout("reloadCounter()", 1600);
}

function isLoaded() {
reloadImage();
reloadCounter();
}
// -->
</script>


What does "/rec/img.cgi?" + countimg + "+out.jpg" mean?
1. Why there is a "?" after .cgi?
2. What does the "+" mean?
3. Are the counting and "+out.jpg" parameters or something else?

I am not familiar with CGI, hope you may help me.
Thank you in advance!


1.) because anything after ? is a query string
2.) + in javascript means joining. "1" + "2" is 12
3.) coutimg in javascript is a variable and +out.jpg is fixed. If they joined together and execute the img.cgi, they are called a query string. (e.g img.cgi?123+out.jpg or img.cgi?somethinghere);