I have a bit of an issue with a function running in chrome that works properly in Safari, both webkit browsers...
I need to customize a variable in a function for Chrome, but not for Safari.
Sadly, I have been using this to detect if it is a webkit browser:
if ($.browser.webkit) {
But I need to detect:
if ($.browser.chrome) {
Is there any way to write a similar statement (a working version of the one above)?
User Endless is right,
code is best to detect Chrome browser using jQuery.
If you using IE and added GoogleFrame as plugin then
code will treat as Chrome browser because GoogleFrame plugin modifying the navigator property and adding chromeframe inside it.
Although it is not Jquery , I use jquery myself but for browser detection I have used the script on this page a few times. It detects all major browsers, and then some. The work is pretty much all done for you.
Sadly due to Opera's latest update
!!window.chrome
(and other tests on the window object) when testing in Opera returns true.Conditionizr takes care of this for you and solves the Opera issue:
I'd highly suggest using it as none of the above are now valid.
This allows you to do:
Conditionizr takes care of other browser detects and is much faster and reliable than jQuery hacks.