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 }

In reply to CGI progress information using Javascript by Celada

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.