Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi How to get browser name in javascript or jquery and its version also,
i need to check in following browsers like IE 10,IE 11 ,Chrome ,Mozila and opera.

I have code but if i open in IE11,it show browser name as Mozila.i am take code from
http://www.w3schools.com/js/js_window_navigator.asp[^]


navigator.appName in all browser it return Netscape
navigator.appCodeName in all browser it return Mozilla


Note: for IE it show Netscape,is it correct ?

here i attach screenshot of ie ,for this i get code from below link,

https://cube3x.com/get-browser-name-and-version-using-pure-javascript/[^]

for mozila and chrome it show correct name like if i run in chrome it show Chrome,42.0.2311.90 for mozila it show Firefox,37.0


screenshot[^]


Regards
Aravind
Posted
Updated 21-Apr-15 0:03am
v3

You can use Plugins like jQuery Browser Plugin[^].

See the Usage[^].
 
Share this answer
 
v2
XML
<html>
<head>
    <script>
        navigator.sayswho = (function () {
            var ua = navigator.userAgent, tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];

            if (/trident/i.test(M[1])) {
                tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
                //return 'IE ' + (tem[1] || '');
                return { name: 'IE ', version: (tem[1] || '') };
            }

            if (M[1] === 'Chrome') {
                tem = ua.match(/\bOPR\/(\d+)/);
                //if (tem != null) return 'Opera ' + tem[1];
                if (tem != null) { return { name: 'Opera', version: tem[1] }; }
            }

            M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];

            if ((tem = ua.match(/version\/(\d+)/i)) != null) {
                M.splice(1, 1, tem[1]);
            }
            alert('Browser Name: ' + M.join(' and Version # '));
            return M.join(' ');
        })();
    </script>
</head>
<body>
</body>
</html>


I was looking for the same and came across above solution. It might be helpful to you.
Ref. site: http://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser
 
Share this answer
 
Comments
Aravindba 21-Apr-15 6:17am    
yes same or less,my second link also same thing.thanx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900