To detect if javascript is enabled, I do it when the user logs in.

So in the login page I have:

                <input type="hidden" id="jsEnabled" name="jsEnabled"
value=""/>
                <input type="submit" class="button" value="Log In"
onclick="document.getElementById('jsEnabled').value='true'"/>

This is inside a WOForm.  The form submits to a direct action that logs the
user in and has this code:

session().isJSEnabled = "true".equals(
request().stringFormValueForKey("jsEnabled") );

The session has this field declared:

public boolean isJSEnabled = false;


John

On Mon, Aug 10, 2009 at 12:39 PM, Mark Gowdy <[email protected]> wrote:

> Hello,
>
> We recently started using the Wonder Ajax framework (which is amazing btw,
> well done guys), but we want to be able to detect if javaScript is enabled
> on the client's browser.
>
> I suspect this is a problem solved by many before, but I cannot seem to
> find a reliable solution.
>
> I have considered setting cookies using client-side javascript, then
> checking for them server-side.
> But conditions can arise where this might not work.
>
> Checking client-side should be the simplest and more reliable way, but I
> have hit a little problem.
> The <noscript> condition is simple (no issues there)
> The <script> condition is less simple.  You have to use a
> document.write('..');
> The problem is now an escaping issue (as demonstrated below):
>
> TheComponent.html
> ---------------------------
> <noscript>
>   <webobject name = ClickedRemoveFromOrder> Remove </webobject>
> </noscript>
>
> <script type="text/javascript">
>   document.write('<wo:AjaxUpdateLink action = "$clickedRemoveFromOrder"
> title = "Remove from basket" class = "remove" updateContainerID =
> "$mediaItem.pk.toString"> Remove </wo:AjaxUpdateLink>');
> </script>
>
> ---------------------------
> Generates:
> ---------------------------
> <noscript> <a class="remove" title="Remove from basket"
> href="/cgi-bin/WebObjects/Shop.woa/wo/3.0.17.10.0.0.1.3.11.1.1.1.1.3.1.5.1.3.1">
> Remove </a>
> </noscript>
>
> <script type="text/javascript">
> document.write('<a href="javascript:void(0);" onclick="AUL.update('246',
> {}, '3.0.17.10.0.0.1.3.11.1.1.1.1.3.1.5.1.3.3');" title="Remove from basket"
> class="remove"> Remove </a>');
> </script>
> ---------------------------
>
> I believe I need to escape the following characters so that they can be
> inserted into the document.write as a parameter.
> ' /
> and probably a few more?
>
> Is there a container I can use that will escape the generated HTML
> automatically?
> Or maybe an additional binding on AjaxUpdateLink (escapeForJavascript)?
>
> Other suggestions welcome.
>
> Thanks in advance,
>
> Mark
>
>
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/johnthuss%40gmail.com
>
> This email sent to [email protected]
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to