kiat has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

Is there any chance that a perl cgi can run on a particular version of a browser but not on another (e.g. Netscape 4 vs Netscape 6.2)? I'm aware that CGIs run from the server so it doesn't really matter what browser the surfer is using. Correct me if I'm wrong.

kiat

Replies are listed 'Best First'.
Re: Is perl cgi browser sensitive?
by Caillte (Friar) on Apr 16, 2002 at 11:10 UTC

    You are right, CGI is server-driven... all the browser gets is the CGI output. Perhaps if you tell us your problem we may be able to identify the cause.

    This page is intentionally left justified.

Re: Is perl cgi browser sensitive?
by ajt (Prior) on Apr 16, 2002 at 12:17 UTC
    In theory there should be no difference, but in practive I'd have to say that there could be a difference - I've seen it myself.

    When the user fills in the form, and presses the submit button, the browser should call your CGI application by POST or GET, with the values from the form. The way the browser collects and sends these values in can be different, so if you expect your paramaters to be filled in a very specific way you may be mistaken. I think the upload field looks different for example.

    When you get the stuff, and do your processing, normally you send something back to the browser. Browsers are supposed to take HTTP headers and content and process them in the same way, but there are clear known differences in this behaviour, IE for example ignores the MIME type, prefering to guess the MIME type from the extension.

    As everyone knows browsers treat content differently too, some are pretty HTML compliant, some less so. Some even change how they parse data based on the MIME type and the first few characters of the content. Both IE6 and Mozilla based browser have Quirks mode, and can render pages very differently - often not what you expect. Some know how to display PNG files, some do not - and so on.

    Finally you have to deal with bugs, some browsers just don't do what they are supposed to, and that can be a real pain.

    Normally when I see strange things like this I get CGI to dump to file everything that comes in and everything that goes out, and then you can decide if it's an unexpected input problem, or a inability to display output problem.

    If you could elaborate on the problem a bit more, I'm sure someone has seen it before and knows what is going on.

    HTH.

Re: Is perl cgi browser sensitive?
by Dog and Pony (Priest) on Apr 16, 2002 at 11:29 UTC
    It should run for just about any browser, no matter what, unlike for example javascript that can be turned off, not implemented, or different between platforms.

    On the other hand, as browsers do render stuff differently, it is possible that the final result may be faulty and/or strange. This has nothing to do with perl or cgi in itself, the result would be the same for the same static HTML. However, it is possible to read what browser is requesting the information (unless it is lying about it *grin*) and customize the HTML to fit that browser better. You can look in $ENV{HTTP_USER_AGENT} to try and determine what browser is used, or even better use the user_agent method in CGI.pm.

    Personally, I think that you should keep your web pages clean and simple, and they can still be good looking :). But some seem to need to cram all the effects, strange layers and whatnot into their pages, and if they are generated, this might help.


    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.
Re: Is perl cgi browser sensitive?
by andye (Curate) on Apr 16, 2002 at 11:29 UTC
    You're right - it shouldn't make any difference.

    But bear in mind that, if the script is running in response to a form submission, the data it *receives* from the browser could vary by browser-version (although, in practise, I've never had a problem with this).

    hth,
    andy.

Re: Is perl cgi browser sensitive?
by dws (Chancellor) on Apr 16, 2002 at 15:38 UTC
    Is there any chance that a perl cgi can run on a particular version of a browser but not on another?

    This is actually two separate questions (input and output), and the answer to both is "yes".

    On input (from browser to CGI) side, as mentioned above, various browsers act differently in how they format a POST. Using CGI.pm, I haven't had problems, though I've heard that Opera does some strange things with POSTS.

    On the output (from CGI to browser) side, the CGI can emit whatever HTML/DHTML/XHTML/etc. it wants, and it's entirely up to the browser to do something sensible. In practice, it's a mess. Every release of every browser so far is buggy or incomplete when it comes to CSS (cascading style sheet) support, for example. Perlmonks isn't the right place to go for treatises on browser misbehavior. Try starting with A List Apart and following the links.

Re: Is perl cgi browser sensitive?
by tmiklas (Hermit) on Apr 16, 2002 at 11:39 UTC
    In general CGI is done server-side and has nothing to do with your browser. I suppose that your problem is the way the page is displayed in different browsers. If that's the problem, then try to identify client's browser and then create documment for that browser.

    Greetz, Tom.