Django检查JavaScript是否开启 [英] Django check if JavaScript is on
问题描述
我需要显示一个非常不同的页面,如果一个用户有JavaScript,而不是没有。
谢谢
如果用户没有JavaScript,我需要显示一个非常不同的页面。
不,你真的没有。您需要做的是使您的页面工作没有Javascript,但然后增强它的Javascript开启的人。没有理由显示完全不同的页面。
在任何情况下,从服务器端检测不到客户端已经启用的方法并不好。一种方法是默认提供非Javascript页面,但是有一个脚本重定向到另一个页面。但这是非常可怕的,因为这意味着对大多数人来说,双重页面的加载。正如我所说,不应该有任何理由这样做。
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
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.
这篇关于Django检查JavaScript是否开启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!