Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't browsers send whether they have javascript enabled/disabled in the request header?

It just seems like something that would be really useful when developing server-side code. If you know that the browser won't be using javascript from the server-side, you could easily accommodate the user. Or if you just felt like it, redirect them to a page that says 'hey... we need you to use javascript for our application' etc.

Does anyone know why this is?

like image 938
aarona Avatar asked Feb 16 '11 22:02

aarona


2 Answers

See the <noscript> tag, here.

I know it's probably not ideal (I don't have enough experience with it to pick it apart) but it certainly gives us enough flexibility to degrade somewhat gracefully.

like image 158
Grant Thomas Avatar answered Nov 02 '22 23:11

Grant Thomas


As handy as it would be to have your server be aware of your browser's Javascript capability before page rendering began, I can see a strange edge case such as:

// hide malicious code from people without javascript
if ($header['javascript'] == 'false') {
    show_regular_safe_website();
} else {
    use_some_nasty_javascript_exploit();
}
like image 33
drudge Avatar answered Nov 03 '22 00:11

drudge