CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
JavaScript excuting cgi



Jan 13, 2000, 2:56 AM

Post #1 of 3 (2881 views)
JavaScript excuting cgi Can't Post

Sorry about all the questions....
can I execution a script using javascript?
can I do something like this...
<Body onload = "execute">
I want to execute a script as soon as the webpage finish loading....and WITHOUT changing the contents of the current page...
is there someway to do that?

Administrator / Moderator

Jan 13, 2000, 3:25 AM

Post #2 of 3 (2881 views)
Re: JavaScript excuting cgi [In reply to] Can't Post

Is there a particular reason you want to use JavaScript? Server Side Includes (SSI) is ideal for that purpose.

I've checked all of my JavaScript books and did not find any commands that will run a cgi script.

If you don't have SSI enabled on your server, you can cheat by using an image tag like this:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

<IMG SRC="/cgi-bin/" HEIGHT=3 WIDTH=3>

Then, you can set up your to something like this:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>



print "Content-Type: text/html\n\n";
print "";
# the rest of your code here

The $|=1 will flush the Perl buffer, which will display the image without waiting for the rest of your program to finish what it's doing.

The print "Content-Type: text/html\n\n"; line will tell the server and browser what kind of content follows.

The print ""; directs the program to display a transparent image. Make sure you upload a transparent image to the location you're using in this line.

While <IMG SRC> sample above uses a HEIGHT and WIDTH of 3 and 3 each, you can use whatever size you wish. It's recommended not to use 1x1 pixel images anymore - WebTV visitors cannot properly display 1x1 images yet.)

I'm sorry I couldn't find a JavaScript solution for you. But for future reference, it may be wise to seek different solutions before you turn to any JavaScript-dependent solution. Many people turn JavaScript off in their browsers, mainly to avoid those annoying pop-up windows that are predominant in "free" web sites.

Best of luck!

[This message has been edited by Jasmine (edited 01-13-2000).]


Jan 13, 2000, 7:28 PM

Post #3 of 3 (2881 views)
Re: JavaScript excuting cgi [In reply to] Can't Post

Well here it is...

I just tested this against my web server..

This will output the text of a cgi file or an image print of a cgi, but not both. Well I could not figure out how to do both. So mabee this will help..

This is I.E......tested only...
Take a look at the SRC="TO CGI/PERL" below...
<SCRIPT LANGUAGE=javascript>
document.write('<IFRAME WIDTH="500" HEIGHT="100"');
document.write('MARGINWIDTH="0" BORDER="0" HSPACE="0" VSPACE="0" ');
document.write('ALIGN="center" SRC=""">');


My CGI script is:
The commented out is the image test....If this was uncomented I would only get the image but not the text.

#!/usr/local/bin/perl -w
$img = "/home/vhost/";
print "Content-Type: text/html\n\n";

## If you want an image the while is important.
#open IMG,$img or die "$!";
# while (<IMG> )
# { print "$_";}
#close IMG or die "$!";
print "Testing this\n\n";


This will also not work in Netscape 4.5, what I used to test with..."Sorry"..

Hope this helps...


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives