如何检测的浏览器是用来访问我的网站? [英] How do I detect what browser is used to access my site?

查看:172
本文介绍了如何检测的浏览器是用来访问我的网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检测一下浏览器(IE,火狐,Opera)的用户访问我的网站?在Javascript,PHP,ASP,Python和JSP你能想到的例子,任何人将是有益的。有没有一种语言无关的方式来获得这些信息?

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 be helpful. Is there a language agnostic way to get this information?

推荐答案

如果它是处理请求,看的用户代理对传入的请求头。

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

更新:如果是用于报告,配置Web服务器登录的用户代理的访问日志,然后运行日志分析工具,例如,的 AWStats的

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.

更新2:仅供参考,它的一般的(不总是,通常)一个坏主意,改变你正在处理基于用户代理的请求的方式

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.

这篇关于如何检测的浏览器是用来访问我的网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆