user-agent 区分IE和Chrome浏览器

IE

IE11

User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko

if(str.indexOf("rv:11") > -1)//判断IE11
	//...

IE10

User-Agent: Mozilla/5.0(compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)

if(str.indexOf("MSIE 10.0")>-1)//判断IE10
	// ...

IE9

User-Agent: Mozilla/5.0(compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)

if(str.indexOf("MSIE 9.0") >-1)//判断IE9
	//....

IE8

User-Agent: Mozilla/4.0(compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)

if(str.indexOf("MSIE 8.0") >-1)//判断IE8
	//....

Chrome

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36

if(str.indexOf("Chrome") >-1)//判断Chrome
	//...
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页