user935375
user935375

Reputation:

Loading a web page how to auto-detect if it has JS. If disabled, switch to HTML

If an user has installed the JavaScript plug-in but is disabled (for security reasons, etc. using no-script or something similar) is there a way to auto-detect (with code, you could suggest the language) that you have JS BUT disabled? If so, switch automatically to the HTML version of the page.

I saw some posts (How to detect if JavaScript is disabled?) but I'm willing to do the switch automatically. Not printing a message saying that "you not have JS enabled" or so on (also, the solution for that question, is the most probable?).

(currently I'm not coding, just asking for general culture question)

Upvotes: 0

Views: 206

Answers (3)

Quentin
Quentin

Reputation: 943518

The standard approach to this is to serve up the HTML version of the page by default, then use JavaScript to layer extra functionality on top.

This is known as progressive enhancement and is a core part of unobtrusive JavaScript.

Upvotes: 1

shadyabhi
shadyabhi

Reputation: 17234

It has a mention of <noscript>...</noscript>. Use that.

Upvotes: 0

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83338

No. If the browser does not want to expose this capability (e.g. disabled, disabled through add-on) you cannot detect it.

<noscript> tag is all you have.

https://developer.mozilla.org/en/HTML/Element/noscript

Upvotes: 0

Related Questions