12月6

js判断浏览器版本、系统型号等

| |
13:49Web开发  From: 本站原创
var userAgent=navigator.userAgent
if(userAgent.index0f("OPR")> -1){
//0pera浏览器,因为Opera浏览器的userAgent也有Chrome和Safari,所以要写在前面 alert("Opera");
}else if(userAgent.index0f("Version")>-1&&userAgent.index0f("Safari")> -1){
//没有更好的办法判断Safari浏览器,只能通过version(版本号)的英又来断,因为别的游览器版本号不是这样写的 alert("Safari"):
}else if(userAgent.index0f("Chrome")> -1){
//谷歌浏览器也有可能是使朋Chrome内核的其他谢览器 alert("Chrome");
}else if(userAgent.index0f("Firefox")>-1){
//火狐浏览器
alert("Firefox");
}else if(userAgent.index0f("compatible")>-1 &&userAgent.index0f("MSIE 10.0")> -1){
//IE 10.0
alert("IE 10.0");
}else if(userAgent.index0f("compatible")>-1&& userAgent.index0f("MSIE 9.0")> -1){
//IE 9.0
alert("IE 9.0");
}else if(userAgent.index0f("compatible")>-1 &&userAgent.index0f("MSIE 8.0")> -1){
//IE 8.0
alert("IE 8.0");
helse if(userAgent.index0f("compatible")>-1&& userAgent.index0f("MSIE 7.0")> -1){
//IE 7.0
alert("IE 7.0");

各浏览器的navigator.userAgent

浏览器  navigator.userAgent
谷歌  Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
火狐  Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Opera  Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36 OPR/45.0.2552.635
Safari  Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
IE11.0  Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; rv:11.0) like Gecko
IE10.0  Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)
IE9.0  Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)
IE8.0  Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)
IE7.0  Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)
Windows NT 区别系统版本

系统版本  Windows NT
win 10  Windows NT 10.0
win 8  Windows NT 6.2
win 7  Windows NT 6.1
vista  Windows NT 6.0
win xp  Windows NT 5.1
win 2000  Windows NT 5.0



来源:Heck's Blog
地址:https://www.heckjj.com/post/568/
转载时须以链接形式注明作者和原始出处及本声明,否则将追究法律责任,谢谢配合!
阅读(1047) | 评论(0) | 引用(0)