Identifying the device requesting a response

寵の児 提交于 2019-12-11 12:36:28

问题


Is it possible for a web server to know which type of device request has been received from?

For example, can a create a website which shows different contents if request came from a computer (Firefox) and something different if it came from iPhone?


回答1:


The way is the User Agent header, as has been said. You best use a list like this one to find out which mobile is it.

When I had to do something like it I stored the unknown received User Agents in a table to find out later about the ones I didn't have stored and thus wasn't able to know for sure what to serve.




回答2:


What Mitch said, with the caveat that it's possible to falsify ones user agent.




回答3:


Check the User-Agent in the Request Header

For full details on HTTP headers, see the specifications at http://www.w3.org/Protocols/.



来源:https://stackoverflow.com/questions/151756/identifying-the-device-requesting-a-response

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