Detecting JavaScript

  • Thread starter Thread starter Nick Goloborodko
  • Start date Start date
N

Nick Goloborodko

Hi,

What is the best way to detect JavaScript and Cookie support of the end user
browser?

TIA
 
Hi Nick,

You can put a <noscript></noscript> tag on your page. Whatever HTML you put
between the tags will be shown in any browser that doesn't support
Javascript or Javascript is disabled. I'm not sure if there is a property
on the server-side that you can check for. If anything you could increment
a hidden input that has runat="server" set with Javascript. When a postback
occurs you can check that variable. If it hasn't incremented or been set to
a value via the Javascript then you'll know that it isn't supported.

I've never tried this but maybe you can even put that hidden field in the
<noscript> block and then check for it when you get back to the server, if
it is present then you'll also know that Javascript is enabled and you won't
need to screw around with programatically setting anything. Good luck!
Ken.
 
Hi Peter,

That will tell you if a browser has Javascript support but it won't tell you
whether it is disabled or not. Ken.
 
Hi,

I was thinking of doing a post back using JavaScript on the first request,
however that just seems clumsy. I do appreciate your help thou :)

If anyone else has some input they can make on this topic it will be greatly
appreciated :)
 
Sending a cookie and testing for its existence,
and writing a Javascript which sets a variable
and testing to see if the variable exists.

There's no way to do it, but by doing it.



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
Hi Nick,

I think Juan and Ken's suggestions are reasonable. If we do need to get
whether the client user has manually disabled the cookie or script, we have
to add some addional roundtrip to clientside to detect the settings.

Thanks,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top