Why does the browser not send enable / disable javascript in the request header?

It just seems like it's really useful when developing server-side code. If you know that the browser will not use javascript on the server side, you can easily place the user. Or, if you just wanted to, redirect them to a page that says: "hey ... we need you to use javascript for our application", etc.

Does anyone know why this is?

+7
source share
5 answers

See the <noscript> tag here .

I know this is probably not perfect (I don't have enough experience with him to make it out), but it certainly gives us enough flexibility to get a little worse.

+2
source

One way I use is to have a landing page / login page. When the user clicks the login button, use javascript to send the results or update the hidden field before publishing the login. If javascript is disabled, javascript will not work, so you can assume that it is disabled.

+1
source

The real reason is that when Netscape came out using JavaScript, they never thought of making the information available in the HTTP headers. Instead, they created the <noscript> .

0
source

It’s convenient, as it would be for your server to know about your browser Javascript capability before starting to render the page, I can see a strange edge case, for example:

 // hide malicious code from people without javascript if ($header['javascript'] == 'false') { show_regular_safe_website(); } else { use_some_nasty_javascript_exploit(); } 
0
source

I believe that the Accept field can be used for a purpose like "Accept: text / javascript". But since it is property, the IETF will never include it in any standards, so large-scale adaptation is hardly possible. Web developers have managed so far.

-one
source

All Articles