2

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.

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.