Hi I started learning express and I want to to know is there is a way to check if JavaScript is enabled/disabled in the browser from server side in express or the only way is to use the no script tag
myCode:
const express = require('express')
const {setCookie,deleteCookie} = require('../controllers/cookiesController')
const cookiesRouter = express.Router()
cookiesRouter.get('/cookies/set',setCookie)
cookiesRouter.get('/cookies/delete:key',deleteCookie)
module.exports = cookiesRouter
exports.setCookie = async(req,res,next)=>{
const browserOption = await req.query
console.log(browserOption.javaEnabled)
if(browserOption.javaEnabled){
res.cookie('javaenabled',browserOption.javaEnabled,{path:'/'});
res.send('cookie Enabled')
}
}
let baseURl = 'http://localhost:4000'
console.log(window.navigator.javaEnabled())
function setCookies(){
let url = `${baseURl}/cookies/set`;
$.ajax({
url:url,
method:"GET",
data: {javaEnabled:navigator.userAgent},
success:function(data){
alert(data)
}
})
}
setCookies()
What I have tried:
i have tried to use the
<noscript>
and this is the only working way to check if the javascript is enabled or not