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

If you built a back office feature that required login, but your code for the user had javascript in there, how would you let perl know to deliver the output that they can support, and if it is not present have it deliver the non-javascript code so that user can use the page too? I just want to know how you would go about telling the script that this user supported javascript, I would then store it in their session so every page could know it...

We are using AJAX with Perl, so the user MUST have javascript enabled or non of the pages work.

What would you do?

Replies are listed 'Best First'.
Re: how would you...
by 7stud (Deacon) on Nov 21, 2009 at 15:20 UTC

    How about delivering both types of content and letting the browser decide which content to display. Do a search for "noscript tags".

    This is a common problem that is considered everyday by web programmers. There are also ways to make the page redirect elsewhere if the browser displays the content of the <noscript> tags, which only happens if javascript is disabled. Or, you can have the javascript redirect to a new page, so people with javascript will go to a different page. However, redirecting like that has search engine implications, which you should investigate.

    I believe the accepted practice is to develop the page without js, and get it working within the scheme of your website. That is what non-js enabled users will see and use. Then you add the bells and whistles with js, which allows users with js enabled to see the extra stuff. In other words, js is not supposed to be responsible for the guts of the page--js is supposed to be used to enhance a page.

    The other option for web programmers who don't care about non js users is to use <noscript> tags to say, "Sorry, this site doesn't work unless you have javascript enabled. Get lost."

Re: how would you...
by ww (Archbishop) on Nov 21, 2009 at 14:26 UTC
    Basically, you're asking how to achive (to Duh!) two mutually exclusive methods:

    user MUST have javascript enabled
    or
    and if it is not present

    So, I would rethink your architecture.