Use navigator.useragent and to judge
PC side:
<script type= "Text/javascript" >
var ua=navigator.useragent.tolowercase ();
if (Ua.match (/webkit/i)) {
Alert ("Chrome");
}else if (Ua.match (/firefox/i)) {
Alert ("Firefox");
}
else if (Ua.match (/opera/i)) {
Alert ("opera");
}else if (Ua.match ("Trident")) {
Alert ("IE");
}
</script>
Mobile side:
<script type= "Text/javascript" >
var ua=navigator.useragent.tolowercase ();
var Neihe=document.getelementbyid (' Neihe ');
if (Ua.match (/qq/i)) {
Neihe.innerhtml= "QQ";
}else if (Ua.match (/micromessenger/i)) {
Neihe.innerhtml= "";
}else if (Ua.match (/oppo/i)) {
Neihe.innerhtml= "OPPO";
}else if (Ua.match (/iphone/i) | | Ua.match (/ipad/i)) {
Neihe.innerhtml= "Safari";
}else if (Ua.match (/opera/i)) {
Neihe.innerhtml= "Opera";
}
</script>
For Navigator.useragent, refer to Http://www.runoob.com/jsref/prop-nav-useragent.html
Note The match () method retrieves the string Object to find one or more text that matches the regexp. The behavior of this method depends to a large extent on whether RegExp has a flag g. If RegExp does not have a flag G, then the match () method can only perform a match in Stringobject. If no matching text is found, match () returns NULL. Otherwise, it returns an array that holds information about the matching text it finds.
JS Judging Browser type