`
yangzisai
  • 浏览: 85895 次
  • 性别: Icon_minigender_1
  • 来自: 东莞
社区版块
存档分类
最新评论

判断浏览器版本

阅读更多

使用

navigator对象的userAgent属性

返回客户发送到服务器的user_agent的头部的值

根据特性来判定:

IE:mozilla/4.0 (compatible; msie 6.0; windows nt 5.2; sv1; .net clr 1.1.4322; infopath.2; .net clr 2.0.50727; .net clr 3.0.04506.30)

 

FireFox:mozilla/5.0 (windows; u; windows nt 5.2; zh-cn; rv:1.9.2.12) gecko/20101026 firefox/3.6.12

 

Opera:opera/9.80 (windows nt 5.2; u; edition ibis; zh-cn) presto/2.6.30 version/10.62

 

所以:navigator.userAgent.toLowerCase()

统一转换为小写

然后navigator.useAgent.toLowerCase().index("mise") != -1;

navigator.useAgent.toLowerCase().index("firefox") != -1;

navigator.useAgent.toLowerCase().index("opera") != -1

来分别判断出对应的浏览器

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics