What is the common way to say “no javascript” in the request header?

天涯浪子 提交于 2020-02-03 04:47:10

问题


I want to tell the server that the browser does not support javascript.

What's the most common approach to do that? (What header is most common?)


回答1:


The HTTP protocol doesn't define any such header. So you could use a custom one. Like:

X-JAVASCRIPT-ENABLED: false

But of course you could have as well used any other header you liked. And by the way may I ask why would the server would care whether the client supports javascript or not? I mean that's the client responsibility. The <noscript> tag is a good way to provide an alternative contents to clients not supporting javascript.




回答2:


Maybe you are ascking about field that should be set normaly when request sent by javascript

 X-Requested-With=XMLHttpRequest

anyway this method doesn't work everywhere and everytime, so you can use in on your own risk.



来源:https://stackoverflow.com/questions/6272096/what-is-the-common-way-to-say-no-javascript-in-the-request-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!