[removed] How to find out if the user browser is Chrome?

后端 未结 15 1863
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 09:41

I need some function returning a boolean value to check if the browser is Chrome.

How do I create such functionality?

15条回答
  •  醉话见心
    2020-11-22 10:31

    To check if browser is Google Chrome:

    var isChrome = navigator.userAgent.includes("Chrome") && navigator.vendor.includes("Google Inc");
    
    console.log(navigator.vendor);
    // "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36 "
    
    console.log(navigator.userAgent); 
    // "Google Inc."
    

提交回复
热议问题