在JS代码中输入console.log(navigator.userAgent)便可打印出以下navigator.userAgent

 

IE的userAgent 判断是否有MSIE

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Mozilla/4.0 (compatible; MSIE 5.0; Windows NT)

 

Firefox的userAgent 

Mozilla/5.0 (Windows; U; Windows NT 5.2) Gecko/2008070208 Firefox/3.0.1

 

Opera的userAgent 判断是否有Opera

Opera/9.27 (Windows NT 5.2; U; zh-cn)

Mozilla/5.0 (Macintosh; PPC Mac OS X; U; en) Opera 8.0

 

 

Safari的userAgent 判断 AppleWebKit Version Mobile Safari

Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13

Mozilla/5.0 (iPhone; U; CPU like Mac OS X) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3

 

Chrome的userAgent 判断是否有 AppleWebKit Chrome

Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13

 

版权声明:本文为liuyunqi原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/liuyunqi/p/6365044.html