.htaccess 能否检测浏览器是否启用或禁用了 javascript?
htaccess 是否可以检测浏览器是否启用或禁用了 javascript,并在禁用 javascript 时写入特定条件?
像这样
if(js)
DirectoryIndex ../locnfo/jsenable.php 否则
目录索引../locnfo/jsdisable.php
Can an htaccess could detect a browser if it's javascript enable or disabled and write a certain condition if javascript is disbled?
Like this
if(js)
DirectoryIndex ../locnfo/jsenable.php
else
DirectoryIndex ../locnfo/jsdisable.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这必须在客户端完成,在其他地方无法检测到。我建议最好的办法是使用类似的东西
,以便仅在启用 Javascript 时才包含该文件。
This has to be done on the client side, it cannot be detected elsewhere. The best thing I would suggest is to have something like
so the file is only included if Javascript is enabled.
不,
.htaccess
文件不能做这样的事情:.htaccess
文件配置 Apache (服务器) 的行为方式 - 而 Javascript 则可以这是在客户端(浏览器)。如果您想检测 Javascript 是否启用,则必须在客户端执行此操作。
关于这一点,这里有几个可能有帮助的问题/答案:
No, an
.htaccess
file cannot do such a thing : an.htaccess
file configures how Apache (server) behaves -- while Javascript is something that's on the client-side (browser).If you want to detect whether Javascript is enabled or not, you'll have to do that on the client-side.
About that, here are a couple of questions / answers that might help :