---
title: "判断浏览器版本"
author: "yangzisai"
date: "2011-08-10T08:12:08Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2011-08-10T08:12:08Z"
id: 1144149
url: "https://danlida.iteye.com/blog/1144149"
---

使用

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

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