问题
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