How do I detect what browser is used to access my site?

前端 未结 11 2149
盖世英雄少女心
盖世英雄少女心 2021-01-13 13:51

How do I detect what browser (IE, Firefox, Opera) the user is accessing my site with? Examples in Javascript, PHP, ASP, Python, JSP, and any others you can think of would b

11条回答
  •  日久生厌
    2021-01-13 14:02

    If it's for handling the request, look at the User-Agent header on the incoming request.

    UPDATE: If it's for reporting, configure your web server to log the User-Agent in the access logs, then run a log analysis tool, e.g., AWStats.

    UPDATE 2: FYI, it's usually (not always, usually) a bad idea to change the way you're handling a request based on the User-Agent.

提交回复
热议问题