<body>
<div id='core'></div>
<div class="hh"></div>
</body>
<script>
var ua=navigator.userAgent.toLowerCase().toString();
var a='',b='',c='',d='';
if(ua.indexOf('msie')!=-1){
a='trident';
switch(offs('msie')){
case '6.0':
c='IE6';
break;
case '7.0':
c='IE7';
break;
}
}
if(ua.indexOf('trident')!=-1){
a='trident';
switch(off('trident')){
case '4.0':
c='IE8';
break;
case '5.0':
c='IE9';
break;
case '6.0':
c='IE10';
break;
case '7.0':
c='IE11';
break;
}
}else if(ua.indexOf('firefox')!=-1){
a='firefox';
b=off('firefox');
}else if(ua.indexOf('chrome')!=-1){
if(ua.indexOf('edge')!=-1){
a='Chromium ';
b=off('chrome');
c='edge';
d=off('edge');
}else if(ua.indexOf('opr')!=-1){
a='Chromium ';
b=off('chrome');
c='opr(Opera)';
d=off('opr');
}else if(ua.indexOf('ubrowser')!=-1){
a='Chromium ';
b=off('chrome');
c='ubrowser(uc)';
d=off('ubrowser')
}else if(ua.indexOf('maxthon')!=-1){
a='Chromium ';
b=off('chrome');
c='maxthon(傲游)';
d=off('maxthon')
}else if(ua.indexOf('qqbrowser')!=-1){
a='Chromium ';
b=off('chrome');
c='qqbrowser(qq)';
d=off('qqbrowser')
}else{
a='Chromium ';
b=off('chrome');
};
}
var cores=''
if(a!=''){
cores='当前浏览器基于<h3 class="core">'+a+'</h4>内核的浏览器,'
}
if(b!=''){
cores=cores+'当前浏览器内核版本为<h4 class="core">'+b+'</h4>'
}
if(c!=''){
cores=cores+'当前浏览器为<h3 class="core">'+c+'</h4>';
}
if(d!=''){
cores=cores+',当前浏览器版本为<h3 class="core">'+d+'</h4>';
}
function off(obj){
for(var i=0 ; i < ua.split(' ').length ; i++){
if(ua.split(' ')[i].split('/')[0]==obj){
var a=ua.split(' ')[i].split('/')[1];
var reg=/(\d*\.?)*/;
return a.match(reg)[0];
}
}
}
function offs(obj){
for(var i=0 ; i < ua.split(' ').length ; i++){
if(ua.split(' ')[i]==obj){
var a=ua.split(' ')[i+1];
var reg=/(\d*\.?)*/;
return a.match(reg)[0];
}
}
}
core.innerHTML=cores;
console.log(ua)
//document.getElementsByClassName('hh')[0].innerHTML=ua
</script>
浙公网安备 33010602011771号