方法一:
var isChrome = window.navigator.userAgent.indexOf("Chrome");
<script>
var isChrome = window.navigator.userAgent.indexOf("Chrome");
if(isChrome !== -1){
console.log(111);
}
else{
console.log(222);
} </script>
方法二:
isChrome == window.google && window.chrome
<script>
var isChrome;
if(isChrome == window.google && window.chrome){
console.log(111);
}
else{
console.log(222);
}
</script>