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

前端 未结 11 1997
盖世英雄少女心
盖世英雄少女心 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条回答
  • Comprehensive list of User Agent Strings from various Browsers

    The list is really large :)

    0 讨论(0)
  • 2021-01-13 14:14

    PHP's predefined superglobal array $_SERVER contains a key "HTTP_USER_AGENT", which contains the value of the User-Agent header as sent in the HTTP request. Remember that this is user-provided data and is not to be trusted. Few users alter their user-agent string, but it does happen from time to time.

    0 讨论(0)
  • 2021-01-13 14:18

    It may be dependent of your setting. With apache on linux, its written in the access log /var/log/apache2/access_log

    0 讨论(0)
  • 2021-01-13 14:22

    check out browsecap.ini. The linked site has files for multiple scripting languages. The browsecap not only identifies the user-agent but also has info about the browser's CSS support, JS support, OS, if its a mobile browser etc.

    cruise over to this page to see an example of what info the browsecap.ini can tell you about your current browser.

    0 讨论(0)
  • 2021-01-13 14:25

    You can do this by:
    - looking at the web server log, OR
    - looking at the User-Agent field in the HTML request (which is a plain text stream) before processing it.

    0 讨论(0)
提交回复
热议问题