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

前端 未结 4 1671
说谎
说谎 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:24

    There is not any simple 'mobile=true' flag. You simply have to check by yourself. From here you can find subset of of values to search (list is rather old, so newer mobile browsers should be added).

提交回复
热议问题