How to detect if JavaScript is disabled?

后端 未结 30 3447
暗喜
暗喜 2020-11-21 07:37

There was a post this morning asking about how many people disable JavaScript. Then I began to wonder what techniques might be used to determine if the user has it disabled.

30条回答
  •  失恋的感觉
    2020-11-21 08:05

    If javascript is disabled your client-side code won't run anyway, so I assume you mean you want that info available server-side. In that case, noscript is less helpful. Instead, I'd have a hidden input and use javascript to fill in a value. After your next request or postback, if the value is there you know javascript is turned on.

    Be careful of things like noscript, where the first request may show javascript disabled, but future requests turn it on.

提交回复
热议问题