How much of a browser compatibility issue is there with perl?

Short answer: as much as you print out.

Perl is a server-side language, JavaScript is a client-side language. That being said, a client doesn't care what generates the content it requests, be it Perl or PHP - just as long as it starts with a valid HEADER.

I have written CGI scripts that were implemented in Perl that created JavaScript code embedded in HTML 'code.' If the JavaScript code is non-compatible across different browsers, it's not Perl's fault - it's MicroSoft's^Wthe browser's fault.

Just remember that the problem is on the client's side. Luckily though, a Perl CGI script can detect what browser was used when it gets a request by checking the value of $ENV{'HTTP_USER_AGENT'}. Here's a real world example:

my $browser = $ENV{'HTTP_USER_AGENT'}; my $explode = ($browser =~ /MSIE (\d+(?:\.\d+)?)/ && $1 >= 5); if ($explode) { # print out IE5 compliant javascript code print " document.form.select.options.remove(0); "; } else { # print out standard (i wish) javascript code print " document.form.select.options[0] = null; "; }

Jeff

happy happy joy joy happy happy joy joy


In reply to (jeffa) Re: Browser compatibility! by jeffa
in thread Browser compatibility! by scottstef

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.