1

I am wondering how do I first detect if Javascript is enabled/disabled. Disabling javascript on this site revealed that stackoverflow uses something called the tag.

Is this like the standard way of doing it? Does it work on all the browsers?Which browser versions does it not work on(ie IE6)?.

Do I just stick in the body or the head of my html page? I saw one site tutorial that stuck it in the head but Visual Studios said that is not XHtml complaint.

Next how do I check if cookies are enabled? Do you do use javascript to figure this out? Or do you use server side? Is there something that works that works on all major browsers or maybe something in jquery that does this?

Thanks

chobo2
  • 75,304
  • 170
  • 472
  • 780
  • I dont think JQuery will be effective when javascript is disabled :) – shahkalpesh Nov 22 '09 at 07:12
  • Really depends on what you want to achieve on a bigger picture. If your app needs both to work, Use ` – o.k.w Nov 22 '09 at 07:32
  • @shahkalpesh I was talking more about cookie detection. From what I seen most ppl do it through javascript. The thought crossed my mind that if javascript is disabled then cookie detection would not work but then I figured they would see the "javascript disable msg" turn that on then see the cookie msg. – chobo2 Nov 22 '09 at 19:34

2 Answers2

3

Use the <noscript> tag to display content when JavaScript is disabled - this isn't quite the same thing as 'detecting' if JavaScript is disabled or not. You can't really tell if JavaScript is enabled or not as the only tool available for doing this across most browsers is JavaScript - which obviously you can't use if it's disabled.

To handle clients without JavaScript support (or with support that has been disabled) you need to use progressive enhancement and unobtrusive JavaScript techniques. Make the page do what you want it to do for clients without JavaScript (the starting point) and then add the additional functionality using JavaScript. As the additions won't be applied without JavaScript enabled you effectively get what you want to achieve.

Same principle applies for cookies - get it to do what you want with no cookies then add the behaviour for when they're found.

FinnNk
  • 3,175
  • 21
  • 24
2

You can use the <noscript> tag to detect whether javascript is disabled or not. Well You cannot actually detect instead you can do something like

<noscript>Javascript is disabled. please enable Javascript</noscript>

Also there is no proper way to check whether cookies are disabled. All you can do is save something in the cookie and try to retrieve them.

Community
  • 1
  • 1
Shoban
  • 22,724
  • 8
  • 60
  • 105