There's no really simple way. The best way to go, in my opinion, is to assume that users won't have Javascript (or that they have it disabled) and make your site as functional as possible.

That said, you might try some sort of cookie magic; Javascript is supposed to be able to set cookies, so you could put some Javascript in the login page that will set a cookie indicating that Javascript is enabled. (You'll need a login page for that ... but that might be as simple as the site's index page) Then have your Perl scripts check to see if that cookie value is set, and those scripts can then act on that information.

<update> here's some code

<head> <script type='text/javascript'> <!-- document.cookie='javascript=1; expires= ' +nextyeartoGMTString(); // that's a durable cookie! // --> </script>

and then something like Adam's approach'll do ya for reading the cookies. </update>

This is not foolproof, though : not every user will have cookies turned on, either.

Philosophy can be made out of anything. Or less -- Jerry A. Fodor


In reply to Re: Perl & JavaScript by arturo
in thread Perl & JavaScript by akm2

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.