Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django check if JavaScript is on

Is there a way in Django (preferably in a view) to check if the user has JavaScript turned on?

I need to display a very different page if a user has JavaScript than if they don't.

Thanks

like image 934
mhost Avatar asked Dec 07 '22 04:12

mhost


1 Answers

I need to display a very different page if a user has JavaScript than if they don't.

No, you really don't. What you need to do is to make your page work without Javascript, but then enhance it for those people with Javascript turned on. There should be no reason to display a completely different page.

In any case, there isn't a good way of detecting from the server side what the client has enabled. One way of doing it is to serve the non-Javascript page by default, but have a single script that redirects to the other page. But this is pretty horrible, since it means a double page load for most people. As I said, there shouldn't be any reason to do this.

like image 121
Daniel Roseman Avatar answered Dec 19 '22 20:12

Daniel Roseman