Dimitri Vorontzov Dimitri Vorontzov - 1 year ago 105
jQuery Question

jQuery: Target ONLY Safari

I'm using this bit of jQuery code to target Safari:

if ($.browser.safari) {
$('#div1').css({'margin-top': '-22px'});
$('#div2').css({'margin-top': '-17px'});

Oddly, it also targets Chrome (at least Mac version). What jQuery code can I use that would ignore Chrome and target only Safari?

I would be grateful for expert advice.

Answer Source

(Edit so that Chrome must not be in the user agent):

if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1)  { 
   //i.e. apply safari class via jquery
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download