This note
Re: Creating a "Progress" page with CGI reminded me of something I did about a year ago in a CGI to show status information to the user while a CGI was generating output. The CGI can generate output as it goes along which appears in the main body of the browser window and mixed in with this, update the user about the stages it is going through by chaning the text in a status line at the top.
#
# If Javascript is disabled in the browser, the effect
# should be that no status line will appear, but
# everything will still work. This is important!
#
# Call makestatusline near the start of execution, just
# after outputting the HTTP header or soon after so that
# the status line will appear ner the top of the page
#
sub makestatusline {
print <<"EOT" ;
<script language="JavaScript1.2"><!--
if (document.getElementById || document.all || document.layers)
document.write("<div id=statusbox><p>Status: </p></div>");
function newstatus(s) {
var e;
if (document.getElementById) {
e = document.getElementById("statusbox");
} else if (document.all) {
e = document.all["statusbox"];
} else if (document.layers) {
e = document.layers["statusbox"];
}
e.innerHTML = "<p>Status: " + s + "</p>";
}
//--></script>
EOT
}
#
# Now call this function once in a while when you have
# something to say to the user. Just make sure you don't
# call it while you are in the middle of outputting an
# HTML tag (finish the tag first, then call it)
#
# INPUT: a string, to display in the status line
sub newstatus {
my ($s) = @_;
$| = 1;
print <<"EOT" ;
<script language="JavaScript1.2"><!--
newstatus("$s");
//--></script>
EOT
}