Detect if javascript enabled in a perl script

Posted on 2006-04-11
Last Modified: 2010-07-27
Hi Experts,

Okay, huge newbie question here: is there a way to detect in a cgi perl script whether or not the user has javascript enabled?

Question by:spike3382
    LVL 39

    Accepted Solution

    I don't know of a way directly, but there are a few things you could do to find out:

    1) If there is a form that gets submitted, have a hidden field.  Then have a javascript function that puts something in that field.  When you process that form, if the field is blank (or default), no javascript.  If it has the updated value, then javascript is enabled.  If you put this on a login page, you know the user will get to it before any other pages.

    2) Have a javascript redirect the web browser to the page with an extra parameter.  Then have your script check for that parameter.
    For example, if you have, have a javascript function redirect to  Then check for the "javascript=yes" part.  If it's there, then javascript is enabled.
    LVL 1

    Author Comment

    Hey, number 1 is a great idea!  It's for a cart, and I know that something has to be added before the user hits the cart, and I can store it in their session variables... which if they aren't there means there's also nothing in the cart.  Perfect!

    Thanks a lot!
    LVL 39

    Expert Comment

    glad it'll work.  thanks for the grade  :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
    Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now