Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI-script doesn't work in Firefox

Status
Not open for further replies.
Looks likee you aren't sending the proper MIME type. Before you start pumping out the HTML, you need to send a header telling the browser to expect HTML instead of plain text:

something like this:
Code:
print "Content-type: text/html\n\n";


-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Is this some type of embedded perl code? Maybe firefox needs to be setup in some way to run the embedded perl code if that's the case.
 
ChrisHunt is right on the money. While his example does resemble a Perl statement, that's not his point. The CGI program must tell the server what type of document it is returning.

NCSA CGI Primer said:
CGI programs can return a myriad of document types. They can send back an image to the client, and HTML document, a plaintext document, or perhaps even an audio clip. They can also return references to other documents. The client must know what kind of document you're sending it so it can present it accordingly. In order for the client to know this, your CGI program must tell the server what type of document it is returning.
NCSA CGI Primer


The difference between Firefox and IE in this context is that, if the document doesn't specify it's content type, IE assumes text/html and Firefox simply shows you the document.

I feel that Firefox's approach in this case is more appropriate, but I'm not sure that either browser is breaking any rules.

CGI and Perl (even Embedded Perl) run on the server side. Neither Firefox or IE can run embedded Perl... but that was just a simple print command that is almost the same in most programming languages.

Try one of these:
Code:
/* Only one newline needed for Java because println already appends one */
system.out.println( "Content-Type: text-html\n" );

/* C */
printf( "Content-Type: text/html\n\n" );

/* PHP or Perl */
print( "Content-Type: text/html\n\n" );

# bash, bourne, or korn shell
echo "Content-Type: text/html\n\n";

The important part is that it has to be the first line of output.

In summary, I never like to make this the only response, but... RTFM

--
-- Ghodmode
 
well, as far as I know, if there is no http header printed, the script will die when it tries to print something to the browser, so there must be some type of header. Maybe the OP will post his code (if it's not too long).
 
Thanks for input, I will try and see if it's work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top