With Chrome entering the browser market, you may find a need in the not too distant future to code some exceptions for it. In case that day comes, here's a quick snippet of JavaScript for detecting if your users are Chromed out:
You can detect Chrome using the following:
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
Chrome's full user agent:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13
Delicious
Digg
StumbleUpon
Propeller
Reddit
Magnoliacom
Newsvine
Furl
Facebook
Google
Yahoo
Technorati
Icerocket
Hi Mark,
Thanks a lot for the snippet.
[...] Guru Prasath wrote an interesting post today onHere’s a quick excerptWith Chrome entering the browser market, you may find a need in the not too distant future to code some exceptions for it. In case that day comes, here’s a quick snippet of JavaScript for detecting if your users are Chromed out: … [...]
[...] voilà, merci Ajaxonomy [...]
/\bchrome\b/i.test(navigator.userAgent)
or
~navigator.userAgent.toLowerCase().indexOf('chrome')
both shorter than
navigator.userAgent.toLowerCase().indexOf('chrome')>-1
The browser indeed is very promising and Firefox / Microsoft IE have to pull up their socks because the real competition is about to begin :D
Post new comment