How to check if the web page is visited by a phone browser or a PC browser?

前端 未结 4 1697
说谎
说谎 2021-01-22 17:53

How to check if a web page has been opened by a mobile browser or a computer browser. I tried this :

name = request.getHeader(\"User-Agent\");

4条回答
  •  我在风中等你
    2021-01-22 18:38

    You could also look at the size of the screen (smaller size would possibly mean a mobile device), which should be accessible through javascript.

提交回复
热议问题