Using jQuery to detect browser

18 Views Asked by At

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?

0

There are 0 best solutions below