0

Is there any function like $(window).width() that can show the browser name as output?

I search a lot but unable to find this type of function for browser name.

bd_user1
  • 75
  • 6
  • There's no built-in JavaScript function, no. – nnnnnn May 04 '14 at 07:40
  • 1
    You could use : http://jquery.thewikies.com/browser/ – sdespont May 04 '14 at 07:41
  • http://www.w3schools.com/js/js_window_navigator.asp Isn't this built-in Javascript? – Seanny123 May 04 '14 at 07:42
  • @Seanny123 - `window.navigator` _is_ built in, yes, but it doesn't actually provide a property that gives you the browser's name. (You would think that the `navigator.appName` property would, but it doesn't.) – nnnnnn May 04 '14 at 07:44

1 Answers1

2

I didn't test it in each browser but this code should work:

var browser = navigator.userAgent;
    browser = browser.split("/");
    browser = browser[2];
    browser = browser.split(" ");
    browser = browser[browser.length-1];

alert(browser);

Here the link is : http://jsfiddle.net/3erQJ/

Cem Demir
  • 152
  • 2
  • 6