TaylorMac TaylorMac - 1 year ago 87
Javascript Question

How to detect if a browser is Chrome using jQuery?

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)?

Answer Source
$.browser.chrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase()); 



UPDATE:(10x to @Mr. Bacciagalupe)

jQuery has removed $.browser from 1.9 and their latest release.

But you can still use $.browser as a standalone plugin, found here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download