Detect Browser Type

var isBrowser = { Chrome: function () { if (navigator.userAgent.indexOf("Chrome") != -1) { return true; } else { return false; } }, Safari: function () { if (navigator.userAgent.indexOf("Safari") != -1) { return true; } else { return false; } }, FireFox: function () { if (navigator.userAgent.indexOf("Firefox") != -1) { return true; } else { return false; } }, IE: function () { if (navigator.userAgent.indexOf("MSIE") != -1) { return true; } else { return false; } }, any: function () { return (isMobile.Chrome() || isMobile.Safari() || isMobile.FireFox() || isMobile.IE()); } }; // How to Use : // if(isBrowser.Chrome()){ // Do some stuff specially for Chrome //}
Contains logic which determines the type of browser. for e.g chrome, safari, firefox etc.

1 Response

Think the "any" method still calls to the mobile detector.
Thanks for sharing!

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.