discover javascript capabilities from server side

  • Thread starter Thread starter Jeremy Chapman
  • Start date Start date
J

Jeremy Chapman

Is there any way via server side code to determine if the browser supports
javascript?
 
Is there any way via server side code to determine if the browser supports
javascript?

You can tell if the browser supports JS using
Page.Request.Browser.JavaScript. If you want to see if it's actually
*enabled*, it is a little harder; you could check if it's supported and
if so send a page containing a Javascript to redirect to a
Javascript-capable version of your page, which clearly would then only
be reached if script were actually enabled.

An example : http://www.15seconds.com/issue/030303.htm

-- PH
 
Genius! Thanks.

Paul Henderson said:
You can tell if the browser supports JS using
Page.Request.Browser.JavaScript. If you want to see if it's actually
*enabled*, it is a little harder; you could check if it's supported and
if so send a page containing a Javascript to redirect to a
Javascript-capable version of your page, which clearly would then only
be reached if script were actually enabled.

An example : http://www.15seconds.com/issue/030303.htm

-- PH
 
Jeremy said:
Is there any way via server side code to determine if the browser supports
javascript?

It's often considered more elegant to determine JavaScript capabilities
on the client and to degrade gracefully if it doesn't.

For example:

<a href="nojs.html" onclick="doSomething();return false">Go</a>

This way, the function is executed if JS is enabled. return false
prevents the HREF to be displayed. If JS is off, the HREF is executed
and nojs.html is displayed, which is a page explaining why the user
experience would be so much better with JS.

Also, if JS is on, you can use object detection to see if only certain
functions are enabled:

if ( document.getElementById )
{
document.getElementById( "..." ).value = "...";
}
else
{
if ( document.all )
{
document.all[ "..." ].value = "...";
}
else
{
alert( "You're doomed" );
}
}

HTH,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top