Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Thanked 0 Times in 0 Posts

    CGI call from window.onload to display word or gif.

    This is part CGI and part JAVA, wasn't sure what one to post under. Last time part was under java but figured that part out. This part has me a little stumped.

    This is working fine except that I can not figure how to change this to get the image or any wording to display before the page loads if no webpagestring found.

    I have tried the Java code at the top of the page, and [head] of the page. Tried other html code in the cgi using EOF and both ends and has not worked either.

    Thanks for your help.

    #!/usr/bin/perl -U
    use CGI header,p;
    use POSIX qw/strftime/;
    $lower_case = lc ($ENV{QUERY_STRING});
      if ($lower_case =~ /webpagestring/) {
          $file = "/var/log/Weblog.txt";
          open(FILE, ">$file");
          print FILE strftime("%A %B %d, %Y - %I:%M %p %Z\n", localtime(time) );
          print FILE " -- IP Address: $ENV{REMOTE_ADDR}\n\t Accessed your page: $ENV{QUERY_STRING}\n------\n";
          system("mail -s 'Web Page visited' myemail\@myDomain.com \< /var/log/Weblog.txt");
          print "Content-type: text/javascript\n\n";
          print "<!--\n";
          print "var x;\n";
          print "//-->\n";
    #get here if no web page.
      print "Content-type: text/javascript\n\n";
      my $image = "image.gif";
      open R,"<$image"; 
      binmode R;
      print "Content-type: image/*\n\n";
      binmode STDOUT;
      while(<R>) { print $_; }
      close R;
      $file = "/var/log/WebPageError.txt";
      open(FILE, ">$file");
      print FILE strftime("%A %B %d, %Y - %I:%M %p %Z\n", localtime(time) );
      print FILE " -- IP Address: $ENV{REMOTE_ADDR}\n\t Accessed no such page: $ENV{QUERY_STRING}\n------\n";
      system("mail -s 'Unknow Page' myemail\@myDomain.com \< /var/log/WebPageError.txt");
    #end of script

    Java Code:
    <script type="text/javascript" language="JavaScript">
    function LaunchCGIprogram() {
    var myImage = new Image();
    myImage.src = "/cgi-bin/WebLog.cgi?" + document.location.href;
    window.onload = LaunchCGIprogram;
    Last edited by brosskgm; 09-29-2012 at 01:27 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts