I want to use $.browser
in my script, but it doesn't work as I want. For example, in Chrome it has properties safari
and webkit
set to true
.
Why does this happen?
Here is a fiddle.
I want to use $.browser
in my script, but it doesn't work as I want. For example, in Chrome it has properties safari
and webkit
set to true
.
Why does this happen?
Here is a fiddle.
In this case it happened because your fiddle use jQuery 1.7.2
in this release you can find:
// Deprecated, use jQuery.browser.webkit instead
if ( jQuery.browser.webkit ) {
jQuery.browser.safari = true;
}
Both browsers chrome
and safari
are based on webkit.
Solutions:
You can use advices from docs like:
$.browser.chrome = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
$.browser.safari = ( $.browser.safari && /chrome/.test(navigator.userAgent.toLowerCase()) ) ? false : true;
You can watch this in action here.
Probably 'cause that's part of Chrome's user agent. See here: http://www.useragentstring.com/pages/Chrome/
What you probably need might be answered in this SO answer.