Easy way to find browsers in JavaScript

Hi all,
Here I have written a JavaScript function to get the browser.

function myBrowser()

{

var browser=navigator.userAgent.toLowerCase();

if (browser.indexOf("msie") != -1)

return 'Internet Explorer';

if (browser.indexOf("firefox") != -1)

return 'Firefox';

if (browser.indexOf("opera") != -1)

return 'Opera';

if (browser.indexOf("safari") != -1)

return 'Safari';

if (browser.indexOf("netscape") != -1)

return 'Netscape';

if (browser.indexOf("mozilla/5.0") != -1)

return 'Mozilla';

if (browser.indexOf("staroffice") != -1)

return 'Star Office';

if (browser.indexOf("webtv") != -1)

return 'WebTV';

if (browser.indexOf("beonex") != -1)

return 'Beonex';

if (browser.indexOf("chimera") != -1)

return 'Chimera';

if (browser.indexOf("netpositive") != -1)

return 'NetPositive';

if (browser.indexOf("phoenix") != -1)

return 'Phoenix';

if (browser.indexOf("skipstone") != -1)

return 'SkipStone';

}

...S.VinothkumaR.

No comments: