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

后端 未结 15 1514
伪装坚强ぢ
伪装坚强ぢ 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:32
    var is_chrome = browseris.chrome
    

    or check ather browsers:

    browseris.firefox
    browseris.ie
    browseris.safari
    

    and olso you can check the version like browseris.chrome7up and etc.

    check all existing information in the 'browseris' object

    0 讨论(0)
  • 2020-11-22 10:34

    all answers are wrong. "Opera" and "Chrome" are same in all cases.

    (edited part)

    here is the right answer

    if (window.chrome && window.chrome.webstore) {
        // this is Chrome
    }
    
    0 讨论(0)
  • 2020-11-22 10:35

    User could change user agent . Try testing for webkit prefixed property in style object of body element

    if ("webkitAppearance" in document.body.style) {
      // do stuff
    }
    
    0 讨论(0)
提交回复
热议问题