Reputation: 9570
I'm pretty sure this is not possible, but just thought I would throw it out there. I want to know if there is a way from the controller (before the view gets rendered) if the browser has JavaScript disabled. I'm sure other people have ran into this working on SEO.
Upvotes: 2
Views: 894
Reputation: 25684
Nope. The server has no view into the client to determine what features the browser has enabled. You can however use a noscript tag to render content if js is disabled.
If you want to record whether or not it is enabled for analytics, how about sending an ajax call in javascript once the page is loaded? If js is disabled, the call won't go through.
Upvotes: 2
Reputation: 3070
No. The only time anything useful comes across in the headers is when a request is via ajax.
As a workaround (and total hack) you could have a script at the very top of the html that sets a cookie and refreshes the page. The backend could then check for that cookie and know if JS is enabled.
Upvotes: 2
Reputation: 276269
Nope. You can only know after the view has been rendered at least once. What you can do in that case is send an ajax request to confirm that javascript is working for this session.
Ofcourse there is always the noscript tag : https://developer.mozilla.org/en-US/docs/HTML/Element/noscript
Upvotes: 2