Skip to content Skip to sidebar Skip to footer

How To Check Javascript Is Enabled Or Not In Node Js Server Side Code

Is this possible to check this using server side code in Node js? OR if not then how can I use conditions like if-else: if enabled then do this else do that In a node.js proj

Solution 1:

You can put a <meta> tag in a <noscript> block to redirect to some special URL:

<noscript><metahttp-equiv=refreshcontent='0; url=http://your.domain/noscript'></noscript>

You cannot of course be 100% certain that users who land on the special URL are there because they've disabled JavaScript, but for people not doing anything weird (other than disabling JavaScript) it works.

Solution 2:

  • You can expose a GET / POST endpoint on your express app - ex: /jsenabled/

  • In the html page - On document ready you can call '/jsenabled'

  • In the jsenabled express handler -infer the user from the session / cookies

  • By default assume user has no js until you get this call

Post a Comment for "How To Check Javascript Is Enabled Or Not In Node Js Server Side Code"