方法一:
var isChrome = window.navigator.userAgent.indexOf("Chrome");
1 <script> 2 var isChrome = window.navigator.userAgent.indexOf("Chrome"); 3 if(isChrome !== -1){ 4 console.log(111); 5 } 6 else{ 7 console.log(222); 8 } 9 10 </script>
方法二:
isChrome == window.google && window.chrome
1 <script> 2 var isChrome; 3 if(isChrome == window.google && window.chrome){ 4 console.log(111); 5 } 6 else{ 7 console.log(222); 8 } 9 </script>
时间: 2024-11-05 16:35:52