0

Question:

I can predict both Chrome and Safari using

$(document).ready(function(){
    $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());

    /* Detect Chrome */
    if($.browser.chrome){
        alert("You are using Chrome!");
        
        /* if it is Chrome then jQuery thinks it's 
           Safari so we have to tell it isn't */
        $.browser.safari = false;
    }

    /* Detect Safari */
    if($.browser.safari){
        alert("You are using Safari!");
    }

});

This code, but I've no idea, how I can know about other browsers like

Opera, UC browser or IE !

Parse method

I can extract navigator.userAgent.indexOf(); using parse method but if every time I've to get -1 then what's the purpose of doing it? How can I use this information?

Community
  • 1
  • 1
Alfha
  • 117
  • 9
  • 1
    Why are you attempting browser detection, you should really be using feature detection for features you are trying to use – phuzi May 18 '20 at 15:21
  • This may help you: [How can I detect browser type using jQuery?](https://stackoverflow.com/questions/19352522/how-can-i-detect-browser-type-using-jquery) – gaetanoM May 18 '20 at 15:22
  • another possibility is: [bowser](https://github.com/lancedikson/bowser) – gaetanoM May 18 '20 at 15:25
  • The string "Chrome" is in the user agent string of almost all major browsers; see http://useragentstring.com/pages/useragentstring.php – Heretic Monkey May 18 '20 at 15:27
  • Thanks Heretic monkey, I got your point! – Alfha May 19 '20 at 09:55

0 Answers0