Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > discover javascript capabilities from server side

Reply
Thread Tools

discover javascript capabilities from server side

 
 
Jeremy Chapman
Guest
Posts: n/a
 
      06-14-2006
Is there any way via server side code to determine if the browser supports
javascript?


 
Reply With Quote
 
 
 
 
Paul Henderson
Guest
Posts: n/a
 
      06-14-2006
> 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

 
Reply With Quote
 
 
 
 
Jeremy Chapman
Guest
Posts: n/a
 
      06-14-2006
Genius! Thanks.

"Paul Henderson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>> 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
>



 
Reply With Quote
 
Laurent Bugnion
Guest
Posts: n/a
 
      06-14-2006
Jeremy Chapman wrote:
> 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
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
server side code access the text of <asp:label> changed by client-side javascript code? nick ASP .Net 3 12-15-2004 06:26 PM
Run Server-side Function *immediately after* executing client-side JavaScript. Guadala Harry ASP .Net 4 06-15-2004 07:04 AM
suggestions on: Create/delete/modify element(s) for server side from Javascript/client-side? Shaul Feldman ASP .Net 0 04-16-2004 09:55 PM
Using SMTP/server-side email capabilities to recieve, process, and return user's materials? Ken Fine ASP General 1 01-26-2004 08:11 PM
Calling client side Javascript from a server side button =?Utf-8?B?Qw==?= ASP .Net 1 01-16-2004 05:56 PM



Advertisments